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

Explain the overview of UDP messaging.

723


Is space a char?

517


What are the types of exceptions?

576


What do you mean by byte code?

501


what are the states associated in the thread? : Java thread

573






what are Hostile Applets?

1591


can java object be locked down for exclusive use by a given thread? : Java thread

516


What is null statement?

518


What are pass by reference and pass by value?

516


What is string english?

525


What is Garbage Collection in Java

599


Does set allows null in java?

495


What is defined as false sharing in the context of multithreading?

494


Is logger a singleton?

511


Can we override private method?

543