• 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

JXAM Qs....

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a Q from JXam.
Consider the following piece of code and select the correct statements.

1. Object o = new String("abcd");
2. String s = o;
3. System.out.println(s);
4. System.out.println(o);
A.
The following is displayed:
abcd
abcd

B.
The code fails to compile at line 1.
C.
The code fails to compile at line 2
D.
The code fails to compile at line 4.
E.
The code can be made to compile by changing line 1 to the following:
String o = new String("abcd");
The answer given is C. But I feel it should be C & E both.
Is it possible for the Inner Class to be the Sub class of the Outer Class ??
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. E should be correct too.
Yes. It is possible for the Inner Class to be the Sub class of the Outer Class. For. eg. the following code compiles fine...
class Outer
{
class Inner extends Outer
{
}
}
HTH,
Paul.

------------------
http://pages.about.com/jqplus
Get Certified, Guaranteed!
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello sonkal,
I have just tried out the program that you have written and found that C and E are correct. I dont understand why the answer is only C. Any one to further clarify on the same if this is wrong. What to do in these cases..
Cheers
softie
 
The first person to drink cow's milk. That started off as a dare from this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic