- We can develop interfaces by using "interface" keyword.
- A class will implements all the methods in an interface.
- By default interface methods are abstract.
- Lets see some interesting java programming interview questions on interfaces.
- Interface programming questions in java
Java interface interview programs part 1: interface programming java
Program #1: what will happen if we define normal methods in interface
- package interfaceinverviewprograms.instanceofjava;
- public interface A{
- /**
- * @java interface interview programming questions and answers for freshers and experienced
- */
- void show() {
- System.out.println("Hello world");
- }
- }
Program #2:java interview programs to practice: Non static variables in interface
- package interfaceinverviewprograms.instanceofjava;
- public interface A{
- /**
- * @java interface interview programming questions and answers for freshers and experienced
- */
- int a,b;
- }
Program #3:java interview programs to practice: which modifiers interface allows
- package interfaceinverviewprograms.instanceofjava;
- public interface A{
- /**
- * @java interface interview programming questions and answers for freshers and experienced
- */
- private int x;
- protected int y;
- }
Program #4:java interview programs to practice: interface allows constructor?
- package interfaceinverviewprograms.instanceofjava;
- public interface A{
- /**
- * @java interface interview programming questions and answers for freshers and experienced
- */
- A(){
- }
- }
No comments