Answered step by step
Verified Expert Solution
Question
1 Approved Answer
QUESTION 2 Output of Line B is: David 21 21 David David 0 null 21 QUESTION 3 Output of Line Cis: Anna 0 Anna null
QUESTION 2 Output of Line B is: David 21 21 David David 0 null 21 QUESTION 3 Output of Line Cis: Anna 0 Anna null O Anna nullo QUESTION 4 Output of Line Dis: null 16 16 null nullo 16 QUESTIONS Output of Line Eis: Ola 15 Ola 12 15 Ola 12 Ola QUESTION 6 Output of Line Fis: Ola Ola 12 Peter 15 QUESTION 7 Output of Line Gis: David 12 David 21 David 12 QUESTION 8 Output of Line His: 12 21 15 16 QUESTION 9 Output of Linelis: Olivia 8 Peter 15 Olivia 12 Ola 8 QUESTION 10 Output of Line) is: Olivia 8 Peter 15 0 000 Olivia 12 Ola 8 QUESTION 1 Output of Line A is: Based on the below code, answer the following Questions public class Student private String name; private int age; public Student(String name, int age) { this.name = name; this.age = age; public class Student Demo { public static void main(String[] args) { Student s1 = new Student("Peter", 15); Student s2 = new Student("David", 21); Student s3 = new Student("Anna"); Student s4 = new Student (16); } public Student(String name) { this.name = name; s1.DisplayInfo(); //Line A S2.DisplayInfo(); //Line B S3.DisplayInfo(); //Line C 54.DisplayInfo(); //Line D public Student(int age) { this.age = age; } public void setAge(int age) { this.age = age; s1.setName("Ola"); s2.setAge(12); s1.DisplayInfo(); // Line E System.out.println($1.getName()); //Line F S2.DisplayInfo(); //Line G System.out.println(s2.getAge()); //Line H s2=51; //Assigning a Reference to Another Reference public void setName(String name) { this.name = name; } public int getAge() { return age; } public String getName() { return name; } public void DisplayInfo() { System.out.println(name + " " + age) } } s1.setAge(8); s2.setName("Olivia"); s1. DisplayInfo(); //Line I $2.DisplayInfo(); //Line ] } nullo null 15 Peter 15 Peter 0
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