Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Consider the following classes to answer questions 16 to 19 . The code fragments in these questions can be assumed to be in an additional
Consider the following classes to answer questions 16 to 19 . The code fragments in these questions can be assumed to be in an additional class - not in class A, B, nor C, nor in a subclass of any of them. 16. ( 2 marks) Indicate what would be printed out from executing the following code fragment. A obj1 = new A();\3 A obj 2= new B();2 A obj3 = new C();2 System.out.println (obj1.p +", " + obj2.p +","+obj3p) (A) 3,2,1 (B) 3,2,2 (C) 3,3,1 (D) 3,3,3 (E) This would cause a compilation error 17. (2 marks) Indicate what would be printed out from executing the following code fragment. A obj1 = new A(); B obj2 = new B() C obj3 = new C() (A) 3,2,1 (B)3,2,2(C)3,3,1 (D) 3,3,3 (E) This would cause a compilation error 18. (2 marks) Indicate what would be printed out from executing the following code fragment. B obj1 = new B(); - B obj2 = new C(); System.out.println(obj1.t +", " + obj2.t); (A) 8,8 (B) 9,9 (C) 8,9 (D) 9,8 (E) This would cause a compilation error 19. (2 marks) Indicate what would be printed out from executing the following code fragment. 1) A obj1 = new A();5 obj2 = new B(); A obj 3= new C(); System.out.println(obj1.m(5) +", " +obj2.m(5) +", " +obj3.m(5)); (A) 5,5,15 (B) 5,5,15,15 (C) 5,10,15 (D) 5,10,15,15
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started