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

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
 
We've gotta get close enough to that helmet to pull the choke on it's engine and flood his mind! Or, we could just read this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic