ExamVeda
Login
Home
11
In Java, can an interface have private methods with implementations?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
12
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();
}
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
13
In Java, can an abstract class extend another class?
Discuss
Answer & Solution
Answer: Option B
Solution:
In Java, abstract classes can extend both abstract and concrete classes.

When an abstract class extends another class (whether abstract or concrete), it inherits the properties and methods of that class.

An abstract class is allowed to inherit from a concrete class and can override or use the methods from the superclass.

Option A is incorrect because abstract classes can extend other classes.

Option C is incorrect since there is no requirement for the superclass to be marked as "static."

Option D is incorrect as the subclass does not need to be marked "final" to extend a class.
14
What is the purpose of the "extends" keyword in Java?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
15
In Java, can an interface extend another interface?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
16
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();
}
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
17
In Java, can an abstract class have non-abstract methods?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
18
What is the purpose of the "default" keyword in Java interfaces?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
19
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();
}
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
20
In Java, can a class implement an interface and extend an abstract class simultaneously?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board