• 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

array extends/impliments

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello friends!
please answer the following question with reason
it is actually from Jargan.com
test3.html
6) Which of the following valid statements
Select all valid answers.
a) an array extends Object
b) an array extends Cloneable
c) an array implements Cloneable
d) an array extends primitive types like int, char, byte
e) None

waiting for reply
 
Ranch Hand
Posts: 1871
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a) an array extends Object
//correct as the JLS says in 4.3.1
An object is a class instance or an array.
b) an array extends Cloneable
an array implements Cloneable and Serializable and does not extend them. remember Cloneable is an interface
c) an array implements Cloneable
// correct see above
d) an array extends primitive types like int, char, byte
// wrong one cannot extend primitive types only Objects
e) None
example program for an array that implements Cloneable

if an array did not implement Cloneable then a CloneNotSupportedException would be raized as in the following program

Regds.
Rahul

[This message has been edited by Rahul Mahindrakar (edited August 03, 2000).]
 
pelluru rao
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
TankQ Rahul.It is fine and enough.
 
pelluru rao
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello Rahul, the code in demo class require
some correction.
x.Clone returns an Object.So it should be
explicitly casted in avoid compile time error.
as
class demo
{
public static void main(String[] args)
{demo x=new demo();
try{
demo y=(demo) x.clone();
}
catch(Exception e){
System.out.println("Exception is " +e);
}
}
}
I think the reason for casting is correct.
If not correct me.
ThankQ
 
Rahul Mahindrakar
Ranch Hand
Posts: 1871
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi pelluru rao,
Guess you really worked on my code. good work. You are right clone() does return an Object which needs to be cast. I have made the necessary corrections.
By the way one can use [ CODE] and [ /CODE] between code blocks to make things look good. Just remove the space between [ C and [ /
Regds.
Rahul

[This message has been edited by Rahul Mahindrakar (edited August 03, 2000).]
 
I'd appreciate it if you pronounced my name correctly. Pinhead, with a silent "H". Petite 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