Question 60 of 76 from exam 1Z0-808: Java SE 8 Programmer I

Question 60 of 76 from exam 1Z0-808: Java SE 8 Programmer I

Question

You are asked to develop a program for a shopping application, and you are given the following information: -> The application must contain the classes Toy, EduToy, and ConsToy.

The Toy class is the superclass of the other two classes.

-> The int caicuiatePrice (Toy t) method calculates the price of a toy.

-> The void printToy (Toy t) method prints the details of a toy.

Which definition of the Toy class adds a valid layer of abstraction to the class hierarchy?

© A) public abstract class Toy{
public abstract int calculatePrice (Toy t);
public void printtoy(Toy t) { /* code goes here */ }
)

© B) public abstract class Toy {
public int calculatePrice (Toy t) ;
public void printToy (Toy t) 3
)

© C) public abstract class Toy {
public int calculatePrice (Toy t);
public final void printToy (Toy t){ /* code goes here */ }
)

© D) public abstract class Toy {
public abstract int calculatepPrice (Toy t) { /* code goes here */ }
public abstract void printToy (Toy t) { /* code goes here */ }

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

A.