What is Interface?

Answer Posted / tarun

In java Interface provides the definition of methods and
final variables. The variables can be declared as final or
not but its can not be changed or modified again. valiable
value can be decide only at the time of declaration.

for more clearance please go through the example given below.

// declaring an interface
public interface MyInterface {

public static final int y = 9;

public void service();
public int method();
public abstract void newmethod();

}

// implementing an interface by a class
public class Class1 implements MyInterface{

/**
* @param args
*/
public Class1(){
System.out.println(y);

}
public void service(){};
int i =9;


public int method(){
final int q = 10;

return q;
}

public void newmethod(){
System.out.println("Tarun");
}

public static void main(String[] args) {
// TODO Auto-generated method stub
Class1 c1 = new Class1();
}

}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is Hierarchy of exception?

652


What is the class in java?

565


What is the range of a character variable?

547


Highest level event class of the event-delegation model?

3507


How to find the largest value from the given array.

528






Explain the importance of import keyword in java?

528


Why to use nested classes in java? (Or) what is the purpose of nested class in java?

530


What is the escape character in java?

517


What are functions in java?

503


Can you give few examples of final classes defined in java api?

568


What is the difference between a synchronized method and a synchronized block?

612


How do I type unicode?

540


how its run?

572


What are annotations in java?

623


Explain oops concepts in detail?

581