
AbstrctClassesInterfaces
Authored by Corporate Support
Professional Development
Used 1+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following allows multiple inheritance in Java?
Abstract classes
Interfaces
Both
None
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What happens if a class implements an interface but does not define all its methods?
It will compile successfully.
It must be declared abstract.
It will throw a runtime exception.
It will automatically inherit default implementations.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is true about abstract classes in Java?
They can be instantiated.
They can have constructors.
They cannot have any method implementations.
They must be final.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
abstract class Animal {
abstract void makeSound();
void sleep() {
System.out.println("Sleeping...");
}
}
class Dog extends Animal {
void makeSound() {
System.out.println("Bark");
}
}
public class Main {
public static void main(String[] args) {
Animal a = new Dog();
a.makeSound();
a.sleep();
}
}
Bark
Sleeping...
Bark
Sleeping...
Compilation Error
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
interface Flyable {
void fly();
}
class Bird implements Flyable {
public void fly() {
System.out.println("Flying high!");
}
}
Bird must declare fly() as abstract.
Bird must implement fly() method.
Flyable can have a constructor.
Flyable can have private instance variables.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
abstract class Vehicle {
abstract void start();
}
interface Electric {
void charge();
}
class Tesla extends Vehicle implements Electric {
void start() {
System.out.println("Starting silently...");
}
public void charge() {
System.out.println("Charging battery...");
}
}
Compilation Error
Starting silently... Charging battery...
Starting silently...
Charging battery...
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
abstract class Shape {
Shape() {
System.out.println("Shape created");
}
abstract void draw();
}
class Circle extends Shape {
void draw() {
System.out.println("Drawing Circle");
}
}
Only "Drawing Circle" is printed
"Shape created" is printed
Both messages are printed
Compilation Error
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Microsoft
or continue with
%20(1).png)
Apple
Others
Already have an account?