Top 10 Core Java Interview Questions And Answers

Java Interview Questions And Answers

You Learn Java in fullstackwithjava.com and Java Interview Questions And Answers

Q.1 – What is a marker interface?

Ans. – An empty interface is called a marker interface.

Q.2 – Can we inherit a static member?

Ans. – Static members are not inherited.

Q.3 – Can we Override the static method?

Ans. – Overriding of static method is not possible.

Q.4 – Can we create more than one static method in the same class?

Ans. – Yes

public class A {
public static void main( String[] args) {
System.out.println(100);
A.test();
}
public static void test(){
System.out.println(200);
}
}
output: 
100
200

Q.5 – Can we create an incomplete static method in an interface?

Ans. – No

public interface A {
public static void test();   // Error
}

Q.6 – Can we create a static complete method is an interface?

Ans. – Yes

Note – in version 8 of java and above we can create the main method in an interface.

public interface A {
public static void main( String[] args) {
A.test();
}
public static void test()  {  
System.out.println(20);
}
}
Output: 20

You Also Learn –

Join TelegramJoin Now
Home PageFull Stack With Java

Leave a Comment