Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
Cloud Application Architecture Patterns: Designing, Building, and Modernizing for the Cloud
this week in the
Cloud/Virtualization
forum!
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
paul wheaton
Paul Clapham
Ron McLeod
Sheriffs:
Jeanne Boyarsky
Liutauras Vilda
Saloon Keepers:
Tim Holloway
Carey Brown
Roland Mueller
Piet Souris
Bartenders:
Forum:
Programmer Certification (OCPJP)
Constructors??
srikanth reddy
Ranch Hand
Posts: 252
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
import java.io.IOException; public class Question72 { public Question72() throws IOException { throw new IOException(); } } Assume that the defination of Question72E begins with the line public class Question72E extends Question72 It is required that none of the constructors of Question72E should throw any checked exception. 1.It can be achived by placing the call to the superclass with a super keyword , which is placed in a try block with a catch block to handle the IOException thrown by the super class. 2.It can be achived by avoiding explicit calls to the base class constructor. 3.It cannot be done in the Java Laungage with the above definition of the base class.
frnds,
without the constructor of the subclass throwing IOException..can i use keep the super in try catch block...
why 1 is not correct..
please explain..
Thanks & Regards<br /> <br />-Srikanth
A Kumar
Ranch Hand
Posts: 982
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi...
super() must be the first statement in a constructor ...if you are trying to
write it yourself..
Below code gives compilation error ...stating that super should be the first statement in a constructor
public class Question72E extends Question72 { public Question72E(){ try{ super(); }catch(IOException e){ } } }
Hope you got it
Whats the answer given in the source ....of this question..
Regards
[ November 04, 2005: Message edited by: A Kumar ]
srikanth reddy
Ranch Hand
Posts: 252
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
thanks kumar...i forgot this concept only...i suppose the answer was it could not be done ....without the subclass throwing the exception ...
thanks
Thanks & Regards<br /> <br />-Srikanth
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Abhilash Quiz
Exceptions
Re:constructors throwing exceptions
Constructor and Inheritance
from abhilash - constructors
More...