Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!
  • 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

threads&inner classes

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Q1. CAN INNER CLASSES BE EXTENDED ?IF YES PLEASE TELL ME WHAT IS WRONG WITH
THIS CODE.

//problem begins here .compiler is unable to find the default constructor of Inner2


Q2.CAN STATIC METHODS BE OVERRIDED ?
ANS . THE ANS TO THIS QUESTION IS PROBABLY NO.
BUT STATIC METHODS CAN BE OVERRIDED AS STATIC .
BUT IT IS GENERALLY NOT MENTIONED IN EXAM WHETHER
TO OVERRIDE THE METHOD AS STATIC OR NON STATIC.
SO WHAT SHOULD BE OUR APPROACH TO THE QUESTION.

Q3.CAN THE INBUILT METHODS LIKE SLEEP(),WAIT(),SUSPEND(),
NOTIFY () ETC BE SYNCHRONIZED.IF YES PLEASE GIVE ME AN ILLUSTRATION.



Q4.DO THESE METHODS MENTIONED ABOVE IN Q3 RELEASE MONITOR WHEN THEY ARE
INVOKED?


Q5 DO SHIFT OPERATORS AUTOMATICALLY WRAPS UP THE VALUE OF PRIMITIVES
WHEN REQUIRED?
EX. int i=1;
i<<31; #ANS IS -2147483648.WHY?
IT SHOULD GENEATE AN ERROR "LOSS OF PRECISION."
2 RAISE TO 31 =2147483648 WHICH IS BEYOND THE LIMIT OF int.

Edited by Madhav:
Doesn't it look good when indented. Its not very difficult you know.....regds - satya


[This message has been edited by Madhav Lakkapragada (edited January 30, 2001).]
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am moving this discussion to Java in General(intermediate)
------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java�2 Platform.
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ravi:
Please indent your source code by using the [ code ] tags
without the spaces. I did that already in your abv post.
Also, please limit the number of qstn in the post to about
two or max. three. Not a rule, but a convenience.
It makes it easier to answer.
regds.
- satya
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For the answer to Q2,
Static methods cannot be overridden to be non-static and vice versa. However, Static methods can be re-declared as static in sub class.
Consider the scenario


This program prints out A rather than B. Static methods are not overridden. Overridding has good meaning only in runtime context and not in static context. Hence overridding static methods by another static method donot hold. It is just redeclaration.
If this is for SCJP, then overridding static by another static method is not valid.
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ravi,
Q3: I would think not. Lets suppose they were. We know that both wait and notify are in the Object class. If someone calls wait then nobody can call notify because only one synchronized method can be entered at one time!
Q4: Only sleep does NOT release the monitor.
Q5: Yes both integers and longs will wrap with shifting. There is no loss of precision. You might get the wrong answer but it will have all the precision of the right answer! This would result in loss of precision:

Regards,
Manfred.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic