What is an abstract class in Java?

3CSE2 understanding Java Abstract Classes 2024

Quiz
•
Computers
•
University
•
Medium
Sharfuddin Mohammed
Used 1+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
An abstract class in Java is a class that cannot be instantiated and may contain abstract methods that must be implemented by subclasses.
An abstract class cannot have any fields or properties.
An abstract class must contain only concrete methods.
An abstract class can be instantiated directly.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How do you declare an abstract method?
Declare an abstract method by using the 'virtual' keyword in a concrete class.
Use the 'abstract' keyword in an abstract class to declare an abstract method.
Use the 'final' keyword in a class to declare an abstract method.
Abstract methods can be declared without any keywords in a regular class.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Can an abstract class have concrete methods?
Yes, an abstract class can only have abstract methods.
No, an abstract class cannot have any methods.
Yes, an abstract class can have concrete methods.
An abstract class can only contain static methods.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the purpose of dynamic method dispatch?
To improve code readability and maintainability.
To reduce memory usage in applications.
To enforce strict type checking at compile time.
The purpose of dynamic method dispatch is to support runtime method resolution and enable polymorphism in object-oriented programming.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Explain polymorphism in Java with an example.
Animal myAnimal = new Animal(); myAnimal.sound(); // Outputs: Animal sound
class Dog extends Animal { void makeSound() { System.out.println("Woof"); } }
class Animal { void makeSound() { System.out.println("Sound"); } }
Example: class Animal { void sound() { System.out.println("Animal sound"); } } class Dog extends Animal { void sound() { System.out.println("Bark"); } } class Cat extends Animal { void sound() { System.out.println("Meow"); } } Animal myDog = new Dog(); Animal myCat = new Cat(); myDog.sound(); // Outputs: Bark myCat.sound(); // Outputs: Meow
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What happens if a subclass does not override an abstract method?
The subclass cannot be instantiated.
The subclass inherits the abstract method's implementation.
The abstract method is automatically implemented.
The subclass can be instantiated with default behavior.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How does method overriding differ from method overloading?
Method overriding allows multiple methods with the same name in different classes.
Method overriding is about redefining a method in a subclass, while method overloading is about having multiple methods with the same name but different signatures in the same class.
Method overriding is used to create new methods in the same class.
Method overloading is when a subclass inherits a method from its parent class.
Create a free account and access millions of resources
Similar Resources on Quizizz
10 questions
Unit 24 - Java Basics

Quiz
•
University
9 questions
Java Interface Quiz

Quiz
•
University
10 questions
java quiz on Encapsulation and Abstraction

Quiz
•
University
15 questions
Java Programming

Quiz
•
University
15 questions
OOP in Python

Quiz
•
University
9 questions
Inheritance + java

Quiz
•
University
10 questions
Java quiz based on inheritance

Quiz
•
University
8 questions
PRG521 Chap8

Quiz
•
University
Popular Resources on Quizizz
15 questions
Character Analysis

Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
10 questions
American Flag

Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension

Quiz
•
5th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25

Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers

Quiz
•
6th - 8th Grade