That is the default behaviour as explained by @ValekHalfHeart in his answer.
If you want to print your objects stuff then you need to override toString
method in your class.
Say I have this code:
class MyClass{
int a,b;
}
So when I make an object of this class and pass it to println
:
public static void main(String args[]){
MyClass m = new MyClass();
m.a = 20;
m.b = 30;
System.out.println(m);
}
It will print something like MyClass@143c8b3
as is your case.
So now if I want that whenever I pass my object to println
it should print something else like values of my variables a
and b
should be printed.
Then I should override tostring
method in MyClass
:
class MyClass{
int a,b;
public String toString(){
return "MyClass values: a = "+a+" and b = "+b;
}
}
So now when I say this
public static void main(String args[]){
MyClass m = new MyClass();
m.a = 20;
m.b = 30;
System.out.println(m);
}
Its going to print MyClass values: a = 20 and b = 30
So you have to do that for your ExamQuestion
class