Question: Read codes and answer questions. //MyClass.java package cn.zjnu.exams; public class MyClass { private int count; String info; public static String message = Good; public


Read codes and answer questions. //MyClass.java package cn.zjnu.exams; public class MyClass { private int         

} private MyClass() { this.count=0; public int getCount() { return count; } public static MyClass 

  

    

  
 
 

Read codes and answer questions. //MyClass.java package cn.zjnu.exams; public class MyClass { private int count; String info; public static String message = "Good"; public MyClass increase() { count++; //return the current object 1/3 } private MyClass() { this.count=0; public int getCount() { return count; } public static MyClass getInstance() ( // Create and return the object of MyClass 2 } this.info= "Good Luck"; //TestMyClass.java package cn.zjnu.exams; public class TestMyClass { public static void main(String[] args) { MyClass mc1 = MyClass.getInstance(); MyClass mc2 = MyClass.getInstance(); mc1.message = "Great"; mc2.message = "Excellent"; MyClass.message = "Nice"; } System.out.println(mc1.message":"+mc2.message+:+MyClass.message); // 3.1 //3.2 3.3 3.4 System.out.println(mc1.info==mc2.info); mc2.info= new String("GoodLuck"); System.out.println(mc1.info==mc2.info); System.out.println(mc1.info.equals (mc2. info)); System.out.println(mc1.increase().increase().getCount());//3.4 Questions: 1) 2) 3) What is the output of the code? Explain the reason. 3.1 3.2 //3.3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Line 31 This line creates two instances of the MyClass class using the getInstance method However the implementation of this method is not shown so it... 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 Accounting Questions!