wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Explain Certpal Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Explain Certpal Question" Watch "Explain Certpal Question" New topic
Author

Explain Certpal Question

vishal mishra
Ranch Hand

Joined: Jul 12, 2010
Posts: 103
Namaste Friends !!

Please explain me why the answer of following question is "This class is fine "
This is the Question-------------------

What is wrong with this class ?


Options are--

1.) There are no abstract methods

2.) This class is fine

3.) The semicolon at #1 should be removed if this class is to compile

4.) This class will get a runtime error if used

5.) There is a compile time error either at #2

6.) There is a compile time error either at #3
7.) There is a compile time error either at #4

I opted option 5 and 7, Certpal explained why option 5 is wrong and explanation given by it is "After Integer.MAX_VALUE the value of the integer is moved back in the negative range in a cyclic manner"

But it doesn't explained why option 7 is wrong and option 2 is correct .

Please explain me why option 2 is correct and opt 7 is not ??

Thanks
Stuart A. Burkett
Ranch Hand

Joined: May 30, 2012
Posts: 679
vishal mishra wrote:Please explain me why option 2 is correct and opt 7 is not ??

Option 7 is wrong because there is nothing on that line that will cause a compiler error. What error were you expecting ?

Option 2 is correct because the class is fine. It's difficult to say anything else without you telling us why you think it is not fine.
vishal mishra
Ranch Hand

Joined: Jul 12, 2010
Posts: 103
So stupid I am...just missed the definition of the method getInteger()




Thanks for replying......
Ramesh Pramuditha Rathnayake
Ranch Hand

Joined: Oct 31, 2012
Posts: 169
    
    1

The reason is the same for 5.)

The return int variable is boxed into Integer class' object. Every object has toString() method.. Therefore no errors..!


Ramesh-X
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1167
vishal mishra wrote:
1.) There are no abstract methods


Java Abstract Classes says -


Absolutely not. Indeed, a class can be abstract without any methods being abstract, although that's relatively rare (see Mark's comment below for an example). On the other hand, if a class has any abstract methods, then it must be declared abstract.


Regards,
Dan


William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
 
Don't get me started about those stupid light bulbs.
 
subject: Explain Certpal Question
 
Similar Threads
can someone explain?
Question from Dan test
jquest question!!!!!!!!
Compile time constant
RE:Question from K&B book