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
what is deadlock? : Java thread
What are the advantages of passing this into a method instead of the current class object itself?
What are the differences between c++ and java?
Explain about main thread in java?
What are the differences between processes and threads?
What is the use of accept () method in java?
What is stringjoiner ?
What is a method in coding?
What is class and its types?
Is main a keyword in java?
Can we access instance variables within static methods ?
How do you check if a string is lexicographically in java?
What is identifier give example?
Can private class be extended java?
Where will it be used?