• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

some ?s!

 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
here are some questions from http://www.certification4career.com/sun/java/programmer/exam1.html
but i think the answers of some ques. given on the site are wrong, so i am putting some ques. here. Some questions are also ambigious, e.g. in the first ques.(option:c), it's not clear whether it is a top-level class or an inner class; so what should we answer? In Q29 the option c can't be correct 'coz if the class is defined in a non-static method then the inner class can access any instance variable of the enclosing class but if the class is defined in a static method then the inner class can only access the static class variables of the enclosing class.
thanx.
ashok.
_______
Q17.The private modifier can be applied to ...
a)A variable
b)A method
c)A class
d)All of the above
_______
Q20.An unary operators operate on a single value
a)True
b)False
_______
Q22.The switch() construct is used to make a choice based upon ...
a)A char value
b)An int value
c)A String value
d)None of the above
_______
Q23.The circumstances that can prevent execution of the code in a finally block are
a)the death of the thread
b)The use of System.exit()
c)It is always guaranteed to be executed.
_______
Q32.Please select invalid statement(s) for a thread
a)You can restart a dead thread
b)You can't call the methods of a dead thread
c)Both of the above
d)None of the above
_______
Q29.An inner class created inside a method can access
a)Any local variables of a method that contain an inner class.
b)Any instance variables of the enclosing class
c)Any final variables of the enclosing class or a method that contain an inner class.
d)None of the above
_______
(fixed link)
[This message has been edited by Marilyn deQueiroz (edited September 06, 2001).]
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the first question
Q17.The private modifier can be applied to ...
a)A variable
b)A method
c)A class
d)All of the above
It is just asking what private can be applied to. If it can be applied to class, then that is a correct answer. You are trying to read too much into the question.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ashok,
Q17.The private modifier can be applied to ...
a)A variable
b)A method
c)A class
d)All of the above
Ans: I would answer 'd'
I don't mind whether it is a inner class or top level class as far as it is a class.
When they ask question like this "What modifiers can we apply for a top level class?", then you know what to answer (public & default).
Q20.An unary operators operate on a single value
a)True
b)False
Answer: a
Example:
int i = 1;
i = 2 + -3;
System.out.println(i);
Q22.The switch() construct is used to make a choice based upon ...
a)A char value
b)An int value
c)A String value
d)None of the above
Answer: a,b
But Java2 Exam Prep by Bill Brogden does not mention about 'char value' in the book, but JLS does.
May be char gets promoted to int or shorter than int primitive.
Someone has to clear this.
Q23.The circumstances that can prevent execution of the code in a finally block are
a)the death of the thread
b)The use of System.exit()
c)It is always guaranteed to be executed.
Answer: a,b
Q32.Please select invalid statement(s) for a thread
a)You can restart a dead thread
b)You can't call the methods of a dead thread
c)Both of the above
d)None of the above
Answer: a
_______
Q29.An inner class created inside a method can access
a)Any local variables of a method that contain an inner class.
b)Any instance variables of the enclosing class
c)Any final variables of the enclosing class or a method that contain an inner class.
d)None of the above
Answer: a,b,c
I am just looking at one side of the coin in this case.
My answers may be wrong, please correct me.
Regards
Usha
 
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Usha,
Q32.Please select invalid statement(s) for a thread
a)You can restart a dead thread
b)You can't call the methods of a dead thread
c)Both of the above
d)None of the above
I think the answer is C
_______
Q29.An inner class created inside a method can access
a)Any local variables of a method that contain an inner class.
b)Any instance variables of the enclosing class
c)Any final variables of the enclosing class or a method that contain an inner class.
d)None of the above
I think the Answer is B and C
Let me know
Thankx
 
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
i agree with Rahgu's answers.
You CAN call methods of a Dead Thread.
Classes defined within the scope of a method can access instance variables from Outer class plus ONLY final variables from the enclosing method..as class lives longer than method..so can access only constants.
thanx
 
Ranch Hand
Posts: 371
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Will death to a Thread cause finally block to be skipped? I don't see how that will happen. Can someone help clarifying the concept?
 
Power corrupts. Absolute power xxxxxxxxxxxxxxxx is kinda neat.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic