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 - 7. Which is possibly a composite class? class Seed { ... } class Fruit { Seed s1 = new Seed(); } class Apple extends Fruits { ... } class Orange extends Apple { ... } class ApplePie { ApplePie a1 = new ApplePie(); } A. Fruit B. Apple C. ApplePie D. Orange E. Seed Part 2 - 8. Given the following code, the output is __. class Apple { int x = 5; } class Orange { int y = 6; } class Tangerine { int z = 7; } class Banana { Apple a1 = new Apple(); Orange o1 = new Orange(); Tangerine t1 = new Tangerine(); public int show() { return a1.x + o1.y + t1.z; } } public class Sample { public static void main(String[] args) { Banana b1 = new Banana(); System.out.println(b1.show()); } } A. 5 B. 6 C. 7 D. 18 E. 5+6+7
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 - 7. Which is possibly a composite class?
class Seed { ... }
class Fruit { Seed s1 = new Seed(); }
class Apple extends Fruits { ... }
class Orange extends Apple { ... }
class ApplePie { ApplePie a1 = new ApplePie(); }
A. Fruit
B. Apple
C. ApplePie
D. Orange
E. Seed
Part 2 - 8. Given the following code, the output is __.
class Apple { int x = 5; }
class Orange { int y = 6; }
class Tangerine { int z = 7; }
class Banana {
Apple a1 = new Apple();
Orange o1 = new Orange();
Tangerine t1 = new Tangerine();
public int show() { return a1.x + o1.y + t1.z; }
}
public class Sample {
public static void main(String[] args) {
Banana b1 = new Banana();
System.out.println(b1.show());
}
}
A. 5
B. 6
C. 7
D. 18
E. 5+6+7
Trending now
This is a popular solution!
Step by step
Solved in 2 steps