Froquiz
Home
Quizzes
Job Tracker
Senior Challenge
Get Certified
Blog
🇬🇧
en
Sign In
Start Quiz
🇬🇧
en
Sign In
Start Quiz
Loading...
Quiz Topics
1
2
3
4
5
6
7
8
9
10
01
/ 10
Which of the following examples of code illustrates the correct use of inheritance-related concepts?
Auto Skip
Report Issue
A.
class Animal { static void eat() { System.out.println("Animal eats"); } } class Cat extends Animal { void meow() { System.out.println("Cat meows"); } }
B.
class Animal { void eat() { System.out.println("Animal eats"); } } class Cat { void meow() { System.out.println("Cat meows"); } } Cat cat = new Cat(); cat.eat();
C.
class Animal { void eat() { System.out.println("Animal eats"); } } class Cat extends Animal { void meow() { System.out.println("Cat meows"); } } Animal animal = new Animal(); animal.meow();
D.
class Animal { void eat() { System.out.println("Animal eats"); } } class Cat extends Animal { void meow() { System.out.println("Cat meows"); } } Cat cat = new Cat(); cat.eat(); cat.meow();
Previous
Next