wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes confusions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "confusions" Watch "confusions" New topic
Author

confusions

gayathri bhushan
Ranch Hand

Joined: Jan 29, 2001
Posts: 39
Hi everybody,
i have some simple,basic questions...hope someone can clear my doubts...
1. does a class having final method be declared final?
2. can overloaded methods throw exception that is not in the other method? what are the exception rules for method overloading?
3. are long and float variables valid if declared as
long l=256788;
float f=8.909923;
ie. without L/l and f following them....?
4. i saw this question s += i; where s is short and i is integer and finally when you evaluate it is stored in short then howcome this expression is valid? are the rules diffrent for short circuit evaluation?
5. which of the following are valid gridbag constraints?
1 ipadx
2 fill
3 insets
4 width
the right answer is 1,2. why is insets not a valid constraint?
i guess it is also a constraint in gridbad constraint class
thank you
gayathri
Michael Burke
Ranch Hand

Joined: Jul 29, 2000
Posts: 103
Insets is a valid gridbag constraint.
Pam Doucette
Greenhorn

Joined: Mar 13, 2001
Posts: 27
Here's some answers from the studying I've been doing...
1. A class with a final method does not need to be final. However, that method can't be overriden in a subclass.
2. Overloaded methods can throw any exceptions they want - there really isn't any relationship other than the name.
3. long l=256788; This declaration is o.k.
float f=8.909923; This will throw a compile error - a literal value with a decimal in it has a default value of a double - so you'd have to declare it as float f=8.909923f or cast it to a float;

[This message has been edited by Pam Doucette (edited March 21, 2001).]
[This message has been edited by Pam Doucette (edited March 21, 2001).]
kapil apshankar
Ranch Hand

Joined: Dec 17, 2000
Posts: 66
Hi Gayathri,
1. A class having final method need not be declared final. You can do so, but then the final modifier of the method will be anyway redundant.
2. Overloaded methods should be able to throw exceptions not thrown in the other method.
3. long variables are valid if declared without l. float without f will throw a compiler error.
4. Yes. The rules for short ckt evaluation are an exception to the rules of arithmetic promotion.
------------------
Hope this helps. Correct me if I am wrong.
Cheers ,
Kapil
[This message has been edited by kapil apshankar (edited March 21, 2001).]


Hope this helps. Correct me if I am wrong.<p>Cheers <img src="smile.gif" border="0"> ,<br />Kapil
shabbir zakir
Ranch Hand

Joined: Nov 12, 2000
Posts: 183
hi everybody
What are the rules for short-circuit evaluation.Thanks in advance
shabbir zakir
Ranch Hand

Joined: Nov 12, 2000
Posts: 183
hi everybody
What are the rules for short-circuit evaluation.Thanks in advance
kamal jaisingh
Ranch Hand

Joined: Feb 23, 2001
Posts: 39
hi
rules for short circuit
short s;
int i;
s+=i // is allowed , int is automatically converted to short
no casting required here.
but s= s+i // illegal , cause this expression will result in an int value , so it has to be expiliclty casted to short.
s= (short) s+i;//now legal,
as stated above s+=i does not require casting.
hope this helps..

Kamal J
gayathri bhushan
Ranch Hand

Joined: Jan 29, 2001
Posts: 39
Thank you all so much. now iam clear....the question regarding the insets constaraint and the long, float declaration are from khalid and so be careful when you do the tests.
thanks to u all again
gayathri
 
Consider Paul's rocket mass heater.
 
subject: confusions