polymorphism + java-visual

polymorphism + java-visual

Professional Development

56 Qs

quiz-placeholder

Similar activities

ITF+ Practice Exam #1

ITF+ Practice Exam #1

Professional Development

56 Qs

Python CH1-3 Review

Python CH1-3 Review

8th Grade - Professional Development

59 Qs

AWS CP Exam 02

AWS CP Exam 02

Professional Development

60 Qs

AZ-900 Practice Test 3

AZ-900 Practice Test 3

Professional Development

51 Qs

MODULO 1

MODULO 1

Professional Development

60 Qs

Web Design (HTML + CSS)

Web Design (HTML + CSS)

Professional Development

54 Qs

Final Theory Test Practice (CCNA)

Final Theory Test Practice (CCNA)

Professional Development

60 Qs

Randy's Networking Quiz 1

Randy's Networking Quiz 1

Professional Development

54 Qs

polymorphism + java-visual

polymorphism + java-visual

Assessment

Quiz

Computers

Professional Development

Practice Problem

Hard

Created by

ANIL KUMAR

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

56 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

The image shows an example of polymorphism in Java. Which of the following methods is called when the area() method is invoked on an object of the Shape class?

Circle area()
Triangle area()
Rectangle area()
Shape area()

Answer explanation

The correct answer is 4. Shape area(). The area() method is defined in the Shape class, and it is overridden by the Circle area(), Triangle area(), and Rectangle area() methods in the respective subclasses. When the area() method is invoked on an object of the Shape class, the overridden method in the specific subclass is called. In this case, the area() method is not overridden in the Shape class, so the Shape area() method is called.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

Which of the following statements is true about the parent class and child classes in the image

The parent class has the deposit() and withdraw() methods, but the child classes do not.
The parent class and child classes both have the deposit() and withdraw() methods, but the child classes can override these methods.
The parent class and child classes both have the deposit() and withdraw() methods, and the child classes cannot override these methods.
The parent class has the deposit() and withdraw() methods, but the child classes have different methods with the same names.

Answer explanation

The image shows that the parent class has two methods, deposit() and withdraw(). The child classes also have these two methods, but they can override them to provide different implementations. For example, the saving child class might override the deposit() method to add a bonus to the amount deposited.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What is the data type of the gender variable in the Author class?

String
char
int
float

Answer explanation

The correct answer is 2. char. This is because the gender variable is declared as a char in the image. The char data type is used to store a single character, such as 'm' or 'f'.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What is the Java mascot about to do?

A. Execute an action.
B. Punch something.
C. Wave hello.
D. Give a speech.

Answer explanation

The answer is supported by the text in the image, which says "Duke is going to punch!". The Java mascot, Duke, is a green, anthropomorphic coffee cup with a punchy expression. The code in the image shows that Duke is a subclass of JavaMascot, which has a method called executeAction(). The executeAction() method in Duke prints out the message "Duke is going to punch!", which indicates that Duke is about to punch something.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

Which of the following is the most common type of polymorphism?

Compile time polymorphism
Runtime polymorphism
Method overloading
Operator overloading

Answer explanation

Runtime polymorphism is the most common type of polymorphism because it allows different objects of a class to respond to the same message in different ways. This is done by overriding methods in the base class. The other types of polymorphism, compile time polymorphism and method overloading, are less common.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

Which of the following statements is true about the code in the image?

A Vehicle object can be added to an ArrayList of Car objects.
A Car object can be added to an ArrayList of Vehicle objects.
Only Car objects can be added to an ArrayList of Vehicle objects.
Only Vehicle objects can be added to an ArrayList of Car objects.

Answer explanation

The code in the image shows that a Vehicle object can be added to an ArrayList of Car objects. This is because Vehicle is the superclass of Car, and so any object of type Vehicle can also be an object of type Car.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

Which type of polymorphism is shown in the image?

Compile-time polymorphism
Run-time polymorphism
Ad hoc polymorphism
Coercion polymorphism

Answer explanation

The image shows the two types of polymorphism in Java: compile-time polymorphism and run-time polymorphism. Compile-time polymorphism is shown in the image with the two boxes labeled "Method Overloading". Run-time polymorphism is shown in the image with the two boxes labeled "Method Overriding".

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?