• 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

Some conflicting points

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. Nonstatic Inner class cannot have static members
��� It is true as per khalid Mughal(page no 230 ex.7.3)
but jqplus has given it is false
2. wait()/notify() are static methods of Object class
True or false
3. The condition expression in an if st. can cintain method calls true/false
4. Is it always that the given number of options must be correct
Please can anyone help me to sundersatnd this
I think 2. is true,3. is false but jqplus has gven false and respectvely
Please help .I am very confused
Savita
 
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) Its true that, Inner classes which are not declared static can NOT have static memebers. Only Static Inner classes can have static members.
2) Wait and notify are Final methods in the Object class.
3) You can pass method call to if condition.Here is a sample code
class test{
test(){}
public boolean testIt(int i){
if (i > 2)
return true;
else return false;
}
public static void main(String args[]){
test t1 = new test();
int j = 3;
if(t1.testIt(j))
{ System.out.println("U can ");}
else {System.out.println("U can NOT");}
}
}
Correct me if I am wrong
Thanx
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can have static fields in a non static inner class if they are final too.
Mughal is wrong on this one.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic