
polymorphism + java-visual

Quiz
•
Computers
•
Professional Development
•
Hard

ANIL KUMAR
FREE Resource
56 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
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
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
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
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
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
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
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".
Create a free account and access millions of resources
Similar Resources on Wayground
60 questions
Oracle Cloud Infrastructure Foundations

Quiz
•
Professional Development
61 questions
jdk,jre,jvm-Visual

Quiz
•
Professional Development
60 questions
Consolidated-Quiz(S3)

Quiz
•
Professional Development
60 questions
HCI Midterm Exam

Quiz
•
Professional Development
60 questions
CBT Sample 2 (App)

Quiz
•
Professional Development
55 questions
M3 R5 Test 15

Quiz
•
Professional Development
60 questions
Unit 2 TECHNOLOGY SYSTEMS

Quiz
•
Professional Development
60 questions
Pra-Exam 1 IAM CERTIFICATE

Quiz
•
Professional Development
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
9/11 Experience and Reflections

Interactive video
•
10th - 12th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
9 questions
Tips & Tricks

Lesson
•
6th - 8th Grade
Discover more resources for Computers
11 questions
All about me

Quiz
•
Professional Development
10 questions
How to Email your Teacher

Quiz
•
Professional Development
15 questions
Fun Random Trivia

Quiz
•
Professional Development
22 questions
Anne Bradstreet 1612-1672

Quiz
•
Professional Development
18 questions
Spanish Speaking Countries and Capitals

Quiz
•
KG - Professional Dev...
14 questions
Fall Trivia

Quiz
•
11th Grade - Professi...
15 questions
Disney Characters Quiz

Quiz
•
Professional Development
15 questions
Quiz to Highlight Q types & other great features in Wayground

Quiz
•
Professional Development