3CSE2 understanding Java Abstract Classes 2024

3CSE2 understanding Java Abstract Classes 2024

University

10 Qs

quiz-placeholder

Similar activities

java quiz based on interface

java quiz based on interface

University

10 Qs

Inheritance

Inheritance

University

10 Qs

Post Test Week 3

Post Test Week 3

University

15 Qs

keistimewaan OOP

keistimewaan OOP

University

15 Qs

AP CSA Inheritance Polymorphism

AP CSA Inheritance Polymorphism

University

10 Qs

Unit 2 Inheritance in Java

Unit 2 Inheritance in Java

12th Grade - University

15 Qs

Object/Abstract/Final in JAVA

Object/Abstract/Final in JAVA

University

10 Qs

OBJECT ORIENTED PROGRAMMING WITH JAVA

OBJECT ORIENTED PROGRAMMING WITH JAVA

University

10 Qs

3CSE2 understanding Java Abstract Classes 2024

3CSE2 understanding Java Abstract Classes 2024

Assessment

Quiz

Computers

University

Medium

Created by

Sharfuddin Mohammed

Used 1+ times

FREE Resource

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is an abstract class in Java?

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

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?