Java Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A, B, C, D, E" is correct. Each question has one correct answer. Thank you. Part 1 - 9. In Java, composition is said to use __ relationship. A. is-a B. part-of C. has-a D. both is-a and part-of E. both has-a and part-of Part 2 - 10. Given the following code, which statement is true? class Water() { ... } class Juice() extends Water { ... } class Apple() { ... } class ApplePie() { Apple a1 = new Apple(); } class AppleJuice() { Apple a1 = new Apple(); Water w1 = new Water(); } A. Juice is a superclass and Water is a subclass. B. ApplePie is a superclass of Apple. C. ApplePie is a composite class that contains an instance of Apple class. D. AppleJuice is a superclass that contains an instance of Apple class and an instance of Water. E. Water is a composite class that contains an instance of Juice.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter2: Using Data
Section: Chapter Questions
Problem 1GZ
icon
Related questions
Question

Java Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A, B, C, D, E" is correct. Each question has one correct answer. Thank you.

Part 1 - 9. In Java, composition is said to use __ relationship.

A. is-a
B. part-of
C. has-a
D. both is-a and part-of
E. both has-a and part-of

Part 2 - 10. Given the following code, which statement is true?

class Water() { ... }
class Juice() extends Water { ... }
class Apple() { ... }
class ApplePie() { Apple a1 = new Apple(); }
class AppleJuice() { Apple a1 = new Apple(); Water w1 = new
Water(); }

A. Juice is a superclass and Water is a subclass.
B. ApplePie is a superclass of Apple.
C. ApplePie is a composite class that contains an instance of Apple class.
D. AppleJuice is a superclass that contains an instance of Apple class and an instance of Water.
E. Water is a composite class that contains an instance of Juice.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT