Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

java programming please Test 2(12 points) Classes and Objects. Read codes and answer questions. // MyClass.java package ch.zjnu.exams; public class MyClass { private int count;

java programming please
image text in transcribed
image text in transcribed
Test 2(12 points) Classes and Objects. Read codes and answer questions. // MyClass.java package ch.zjnu.exams; public class MyClass { private int count; String info; public static String message = "Good"; public Myclass increase() { count++; 1/return the current object 1/3 private MyClass() { this.count=8; this.info - "GoodLuck"; public int getCount() { return count; } public static MyClass getInstance() { // Create and return the object of MyClass 2 } } //TestMyClass.java package cn.zjnu.exams; public class TestMyClass { public static void main(String[] args) { MyClass mci - MyClass.getInstance(); Myclass mc2 - MyClass.getInstance(); mc1.message - "Great"; mc2. message = "Excellent"; MyClass.message - "Nice"; System.out.println(nci.message+ :*+mc2. message":"#MyClass.message);// 3.1 System.out.println(mc1.info-mc2.info); //3.2 mc2.info = new String("GoodLuck"); System.out.println(mci.info--mc2.info); //3.3 System.out.println(mci.info.equals(mc2. info)); System.out.println(mci. increase().increase().getCount();//3.4 3 } Questions: 1 2) 3) What is the output of the code? Explain the reason. 3.1 3.2 3.3 3.4

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_2

Step: 3

blur-text-image_3

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

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 2012 Proceedings Part 2 Lnai 7197

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284892, 978-3642284892

More Books

Students explore these related Databases questions