aspose file tools
The moose likes Java in General and the fly likes threads&inner classes Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "threads&inner classes" Watch "threads&inner classes" New topic
Author

threads&inner classes

RAVI BHAWNANI
Greenhorn

Joined: Jan 29, 2001
Posts: 4
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).]
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
I am moving this discussion to Java in General(intermediate)
------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java�2 Platform.


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

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

Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Sridevi Shrikanth
Ranch Hand

Joined: Jan 11, 2001
Posts: 31
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.
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: threads&inner classes
 
Similar Threads
Accessing var in innerclasses
Inner Classes
inner, outer disturbance?????
threads&inner classes
Can a class extend a inner class?