Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

QUESTION 1 Output of Line A is: Based on the below code, answer the following Questions public class Student { public class StudentDemo { private

image text in transcribed

QUESTION 1 Output of Line A is: Based on the below code, answer the following Questions public class Student { public class StudentDemo { private String name; public static void main(String[] args) { private int age; Student s1 = new Student("Peter", 15); public Student(String name, int age) { Student s2 = new Student("David", 21); this.name = name; Student s3 = new Student("Anna"); this.age = age; Student s4 = new Student (16); } public Student(String name){ s1.DisplayInfo(); //Line A this.name = name; 52.DisplayInfo(); //Line B } S3.DisplayInfo(); //Line C public Student(int age){ $4.DisplayInfo(); //Line D this.age = age; } s1.setName("Ola"); public void setAge(int age) { s2.setAge(12); this.age = age; } s1.DisplayInfo(); //Line E public void setName(String name) { System.out.println(s1.getName()); // Line F this.name = name; } S2.DisplayInfo(); //Line G System.out.println(s2.getAge()); //Line H public int getAge(){ return age; s2=s1; //Assigning a Reference to Another Reference } public String getName() { s1.setAge(8); return name; s2.setName("Olivia"); } public void DisplayInfo(){ s1.DisplayInfo(); //Line I System.out.println(name + + age). S2.DisplayInfo(); //Line J } } } nullo null 15 Peter 15 Peter 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions