Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

threads&inner classes  RSS feed

 
RAVI BHAWNANI
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q1. CAN INNER CLASSES BE EXTENDED ?IF YES PLEASE TELL ME WHAT IS WRONG WITH
THIS CODE.
class Inne{
int i=10;
public void add(){
System.out.println("add");
}
static class Inner1 {
static int j=20;
public static void sub(){
System.out.println("sub");
}
//problem begins here .compiler is unable to find the default constructor of Inner2
static class Inner2 extends Inner1.Inner2 {
static int j=20;
public static void div(){
System.out.println("div");
sub();
}//end of div
}//end of Inner2
public static void main(String args[]){
Inner in=new Inner();
Inner.Inner1 in1=in.new Inner1();
Inner.Inner1.Inner2 in2=in1.new Inner2();
in2.div();

}//end of main()
}//end of Inner1
}//end of Inner



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.
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!