Question 1 of 25
Hints left: 3
Q1
What is the purpose of the "default" keyword in Java interfaces?
Q2
In Java, can an abstract class have non-abstract methods?
Q3
In Java, can a class implement multiple interfaces?
Q4
At line number 2 in the following code, choose 3 valid data-type attributes/qualifiers among "final, static, native, public, private, abstract, protected" public interface Status { /* insert qualifier here */ int MY_VALUE = 10; }
Q5
What is the result of the following code snippet? interface MyInterface { void myMethod(); } public class MyClass implements MyInterface { public void myMethod() { System.out.println("Implementation"); } public static void main(String[] args) { MyInterface obj = new MyClass(); obj.myMethod(); } }
Q6
In Java, can an interface have private methods with implementations?
Q7
What is the purpose of the "extends" keyword in Java?
Q8
In Java, can an abstract class extend another class?
Q9
Which of these can be overloaded?
Q10
Which keyword is used to declare an interface in Java?
Q11
What is an interface in Java?
Q12
What will be the output of the following Java program? class Abc { public static void main(String[]args) { String[] elements = { "for", "tea", "too" }; String first = (elements.length > 0) ? elements[0]: null; } }
Q13
What is the purpose of the "implements" keyword in Java?
Q14
Which keyword is used to define an abstract method in Java?
Q15
In Java, can an interface have fields (member variables)?
Q16
What is the result of the following code snippet? interface MyInterface { default void myMethod() { System.out.println("Default Implementation"); } } class MyClass implements MyInterface { public static void main(String[] args) { MyInterface obj = new MyClass(); obj.myMethod(); } }
Q17
What is the purpose of an abstract method in an abstract class or interface?
Q18
In Java, can an interface extend another interface?
Q19
What will be the output of the following Java program? class A { int i; public void display() { System.out.println(i); } } class B extends A { int j; public void display() { System.out.println(j); } } class Dynamic_dispatch { public static void main(String args[]) { B obj2 = new B(); obj2.i = 1; obj2.j = 2; A r; r = obj2; r.display(); } }
Q20
In Java, can an abstract class be instantiated?
Q21
What is the purpose of an abstract class in Java?
Q22
What will be the output of the following Java code? class test { int a; int b; void meth(int i , int j) { i *= 2; j /= 2; } } class Output { public static void main(String args[]) { test obj = new test(); int a = 10; int b = 20; obj.meth(a , b); System.out.println(a + " " + b); } }
Q23
What is the result of the following code snippet? abstract class MyAbstract { abstract void myMethod(); } class MyClass extends MyAbstract { void myMethod() { System.out.println("Implementation"); } public static void main(String[] args) { MyAbstract obj = new MyClass(); obj.myMethod(); } }
Q24
Which of this keyword can be used in a subclass to call the constructor of superclass?
Q25
Which of the following can contain both abstract and non-abstract methods?