consider the following definition of the class Myclass: public class Myclass{ private static int count = 0; private int x; } public Myclass(int i){ x = i; } public void incrementCount(){ Count++; } public void printX(){ System.out.println("Value of x : "+ x); } public static void printCount(){ System.out.println("Value of Count : " +count); } } public class MyclassDemo{ public static void main(String[] args){ MyClass myObject1 = new MyClass(5); MyClass myObject2 = new MyClass(7); } }   what is the outputof the following java code? (Assume that following statements are written inside main) a) myObject1.printX(); output: b) myObject1.incrementCount(); output: c) myClass.incrementCount(); output: d) myOject1.printCount(); output: e) myObject2.printCount(); output: f) myObject2.printX(); output:

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 20RQ
icon
Related questions
Question

consider the following definition of the class Myclass:

public class Myclass{

private static int count = 0;

private int x;

}

public Myclass(int i){

x = i;

}

public void incrementCount(){

Count++;

}

public void printX(){

System.out.println("Value of x : "+ x);

}

public static void printCount(){

System.out.println("Value of Count : " +count);

}

}

public class MyclassDemo{

public static void main(String[] args){

MyClass myObject1 = new MyClass(5);

MyClass myObject2 = new MyClass(7);

}

}

 

what is the outputof the following java code?

(Assume that following statements are written inside main)

a) myObject1.printX();

output:

b) myObject1.incrementCount();

output:

c) myClass.incrementCount();

output:

d) myOject1.printCount();

output:

e) myObject2.printCount();

output:

f) myObject2.printX();

output:

g) my Object1.setX(14);

output:

h) myObject1.incrementCount();

output:

i) myObject1.printX();

output:

j) myObject1.printCount();

output:

k) myObject2.printCount();

output:

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 6 images

Blurred answer
Knowledge Booster
Reference Types in Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,