• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

doubts on Mock exams

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. Can I create the following
InnerClass i = new InnerClass();
in the main method of the outer class enclosing the Innerclass (assuming both the Outer and InnerClass are public

2. Is wait() considered to be an instance method of Thread class? (since it is inherited from Object)
3. A static reference cannot be made through non static method or code block.(T/F)
4. Math is not immutable (it is final class) (T/F)
5. What are the signed shift operator(s)?
6. Can I have static modifier with transient for a variable?
7. Will object references in local methods be initalised to null by default?
8.
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well lets see
Ans according to the question nos
1. Is your InnerClass static coz if so then you can specify as InnerClass i = new InnerClass();
Now why whenever I see such code I forget about inner class and think in a simple terms inorder for a reference / object to be created the class should be accesible. what I mean is you are trying to create an object of class InnerClass in main static method, so is InnerClass which is non static accessible in main method I don't think so.
2. Good theory but it is not in terms of the word instance method, I think (my understanding) you can only say that a method is instance of a particular class if it overrides it, which is not in the case of Thread class, so if you think in OO methodlogy the method wait() even though inherited from object into Thread it still belongs to Object hence the answer is no.
3.Sorry didn't understand the question pls give more info.
4.Well in a way you are correct but I don't think the difference immutable are used on objects, where as final is used on class but both literal meaning is the same.
5. Signed shift operators are >> & <<
6. well java compiler will not complain but as you know that trasient is used to prevent serlization of a variable and static variable is any way not serialized hence it is not needed or useless to specify transient on static variable.
7. No, compiler will complain if they are not initilized before use.
8.
A. is wrong coz no throws at all compiler will complain
B. Is fine as BaseException can handle subexception as well.
C.Is also fine same as B, and runtimeexception need not be in throws clause anyway.
D. It is fine as Exception is the Base of the BaseException hence can handle both BaseException and SubException
E. is wrong coz no throws for BaseException and subException types.
 
preeti khane
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
on 3. what the exam asked was whether in a non-static method or block I can make a call to a static method or refer to a static variable....The exam said False.. and I was thinking True
on 6. why is << signed shift operator, it does not preserve sign in any way does it....
on no 8. my answers were B, C and D... but the exam answers said only C and D...Hence wanted to know the clarification
 
Lawrence Chettiar
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
on 3. you are right, It clearly looks a error in the mock exam, which mock exam was it try to send a email to the website owner.
on 6. oops you are correct, and I digged into JLS and indeed it says "The shift operators include left shift <<, signed right shift >>, and unsigned right shift >>>" that means only >> is the signed operator and >>> is the unsigned operator. But I think some of the mock exams takes both as correct answer thats how I remember them. well I may be wrong. Thanks alot for reminding me that.
on 8. Again same as no 3, you are right seems answer wrong in the mock exam contact the author.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic