Question: Given the following programs, write the output in Object-oriented programming public class A { public class Main private int x; public AO { System.out.println(Good luck..);
Given the following programs, write the output in Object-oriented programming 
public class A { public class Main private int x; public AO { System.out.println("Good luck.."); public static void main(String[] args) { A al = new A(5); A a2=al; A a3 = new A(10); A a4 = method(al,a3); A a5=al; a2 = new A(15); public A(int x) { this.x = x; public int getX() { return x; 3 System.out.println("al:"tal.getX(); System.out.println("a2: "+a2.getX(); System.out.println("a3 : "+a3.getX(); System.out.println("a4 : "+a4.getXO): System.out.println("a5 : "+a5.getX(); public void setX(int x) { this.x = x; A a6 = new AC; } static A method(A al,A a2){ al.setX(20); a2.setX(30); return new A(40); 3 }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
