instanceof java
Posts: 576
Nickname: instanceof
Registered: Jan, 2015
instanceof java is a java related one.
Java interface programming questions
Posted: Jul 24, 2016 11:31 AM
This post originated from an RSS feed registered with Java Buzz
by instanceof java.
Original Post: Java interface programming questions
Feed Title: Instance Of Java
Feed URL: http://feeds.feedburner.com/blogspot/TXghwE
Feed Description: Instance of Java. A place where you can learn java in simple way each and every topic covered with many points and sample programs.
Latest Java Buzz Posts
Latest Java Buzz Posts by instanceof java
Latest Posts From Instance Of Java
Advertisement
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.
Java interface interview programs part 1: 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"); } } Click for Output
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; } Click for Output
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; } Click for Output
compile time error: Illegal modifier for the interface field A.x; only public, static & final are permitted compile time error: Illegal modifier for the interface field A.y; only public, static & final are permitted 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(){ } } Click for Output
Compile time error: interface cannot allow constructor
Read: Java interface programming questions