Question: 2. Given class A1, A2, A3 below, what gets printed after executing the following code: Answer: package a3; class A1 ( int age =

  • 2. Given class A1, A2, A3 below, what gets printed after executing 

2. Given class A1, A2, A3 below, what gets printed after executing the following code: Answer: package a3; class A1 ( int age = 20; public String toString() { return "years"; } public int getAge ( ) { return age; } public void updateAmount (float f) { f public void updateAge (int i) { age; } age = i; } class A2 extends Al ( { updateAmount (25); } public A2() public String toString() { } return "age: " + ( getAge () ); public class A3 ( public A3() { } { A2 b new A2 (); Al a new Al(); System.out.println(a + " System.out.print( b); } public static void main(String[] args) A3 a new A3(); = Al b new Al(); System.out.println (b.getAge () ); System.out.println(b + " = " ); System.out.print (b.age +1+ "old" );

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

There are several syntax errors and inconsistencies in the provided code snippet Ill correct them fi... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!