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:
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:
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 6 images