wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes JQ Plus Questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "JQ Plus Questions" Watch "JQ Plus Questions" New topic
Author

JQ Plus Questions

vijay malhotra
Greenhorn

Joined: Nov 26, 2000
Posts: 26
Please give correct answers for the following 2 questions from JQ Plus
Q1.Which of the following statements regarding inner classes are true ?
Select 3 correct choices
a) A non static inner class may have static members
b) Anonymous inner classes cannot have any extends or implements clause
c) Anonymous inner classes can only be created for interfaces
d) Anonymous inner classes can never have initialization parameters
e) Anonymous inner classes cannot be static
////****////
Q2.Given :

byte b = 2;
char c = 2;
short s = 2;
int i = 2;
Which of the following expressions are valid ?
Select all 3 correct answers
a) s = b * b;
b) i = b << b;
c) s <<= b;
d) c = c + b;
e) s += i;
PLEASE ALSO GIVE YOUR REASONS FOR THE CORRECT ANSWERS
Stevie Kaligis
Ranch Hand

Joined: Feb 04, 2001
Posts: 400
Q1 :
answer : a,b,e
answer a correct, n.s.i.c may have static final field (i.e constant value).
Q2 :
answer :
a) s = b * b; //INCORRECT, s is short, result b*b will be at least integer, need explicit cast
b) i = b << b; //CORRECT, doesn't need explicit cast
c) s <<= b; //CORRECT, will be evaluated: s = (short)(s << b)
d) c = c + b; //INCCORECT, same as point a
e) s += i; //CORRECT, will be evaluated s = (short)(s + i)

stevie
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JQ Plus Questions