Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

confusions

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Insets is a valid gridbag constraint.
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi everybody
What are the rules for short-circuit evaluation.Thanks in advance
 
shabbir zakir
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi everybody
What are the rules for short-circuit evaluation.Thanks in advance
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic