Question: 15. (35) Consider the following program segment and student class. Student to - new Student (17); System.out.println(tom.getAge()); Student clone - tom.copy(); alone.setAge(21), System.out.println(clone.getAge()); System.out.println(ton.getAge()); class
15. (35) Consider the following program segment and student class. Student to - new Student (17); System.out.println(tom.getAge()); Student clone - tom.copy(); alone.setAge(21), System.out.println(clone.getAge()); System.out.println(ton.getAge()); class Student private int age; public Student(int a) { age = a; } public Student copy() { return this; } public int getAge() { return age; ) public void setAge(int a) { age - a; } What is printed as a result of executing the program? (A) 17 (B) 17 (D) 21 (E)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
