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

JQ Plus Questions

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Something must be done about this. Let's start by reading this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic