Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JQ Plus Questions

 
vijay malhotra
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic