File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "JQ Plus Questions" Watch "JQ Plus Questions" New topic

JQ Plus Questions

vijay malhotra

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;
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)

I agree. Here's the link:
subject: JQ Plus Questions
It's not a secret anymore!