Less than 42 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Errata - John Meyers Exam  RSS feed

 
Najmunnisa Sageer
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

First of all let me thank for the free online John Meyers mock exam.This exam has helped me a lot in improving my generics knowledge.

In one of the mock question

class test
{
int x; test(int input) { x = input; }
public static void main( String args[] )
{
System.out.println( new test(3).equals(new test(3)) );
}
public boolean equals( Object o)
{
return ( (test)o ).x == x;//1
}
}

Its a compiler error on the line 1 and the answer is displayed as
"Prints true".


Najmunnisa Sageer.
 
Arijit Daripa
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Najmunnisa Sageer:
Hi,

First of all let me thank for the free online John Meyers mock exam.This exam has helped me a lot in improving my generics knowledge.

In one of the mock question

class test
{
int x; test(int input) { x = input; }
public static void main( String args[] )
{
System.out.println( new test(3).equals(new test(3)) );
}
public boolean equals( Object o)
{
return ( (test)o ).x == x;// 1
}
}

Its a compiler error on the line 1 and the answer is displayed as
"Prints true".


Najmunnisa Sageer.



Everything is OKAY.
Compiler is happy and proper output is displayed.
[ August 18, 2008: Message edited by: ARIJIT DARIPA ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!