C
Chad
Let's say I have the following...
public class Main {
public static void main(String[] args) {
MyStack stack = new MyStack();
System.out.println("Instance of Object: "
+ (stack instanceof Object));
System.out.println("Instance of MyStack: "
+ (stack instanceof MyStack));
}
}//end Main
class MyStack {
private int size = 0;
public int tripleIt(int newSize) {
size = newSize;
return 3 * size;
}
}
I get the following output when I run this code...
Instance of Object: true
Instance of MyStack: true
How can there be an instance of MyStack when I never made a
constructor for it? That is, I never create a MyStack object.
Chad
public class Main {
public static void main(String[] args) {
MyStack stack = new MyStack();
System.out.println("Instance of Object: "
+ (stack instanceof Object));
System.out.println("Instance of MyStack: "
+ (stack instanceof MyStack));
}
}//end Main
class MyStack {
private int size = 0;
public int tripleIt(int newSize) {
size = newSize;
return 3 * size;
}
}
I get the following output when I run this code...
Instance of Object: true
Instance of MyStack: true
How can there be an instance of MyStack when I never made a
constructor for it? That is, I never create a MyStack object.
Chad