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 –
- What is Abstract Class in Java
- What is Lambda Expression in Java 8
- What is Exception Handling in Java
- Types of Exceptions in Java
- What is inheritance in Java
- What is the Final Keyword in Java
- What is Interface in Java
- What is Wrapper Class in Java
- Break Keywords in Java with Example
- What is Method In Java With Example
- What is Constructor in Java With Example
- What is Polymorphism in java
- What is a non-static variable in java
- Types of access specifiers in java
- What is the local variable in java
- Types of loops in java with program
- Remove duplicate elements in an Array in java
- What is var type in java
- What is a static variable in java
- What is the difference between return and return value?
Join Telegram | Join Now |
Home Page | Full Stack With Java |