Two Laptop Bag*
The moose likes Beginning Java and the fly likes Abstract classes - instantiation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Abstract classes - instantiation" Watch "Abstract classes - instantiation" New topic
Author

Abstract classes - instantiation

Arnb Sen
Ranch Hand

Joined: Feb 23, 2004
Posts: 145
Hi,

I read somewhere


A class that is abstract may not be instantiated (ie, you may not call its constructor)


Can someone please elaborate on this ?

This code works --



Regards,<br />Arnab
Paul Santa Maria
Ranch Hand

Joined: Feb 24, 2004
Posts: 236
More to the point, please recompile with "javac -Xlint:unchecked" (or better, "javac -Xlint:all") and find out for sure exactly what the compiler disagrees with!


Paul M. Santa Maria, SCJP
Dave Kairys
Ranch Hand

Joined: Sep 09, 2005
Posts: 33
This has to do with polymorphism. All abstract methods must be implemented(or overridden). In order to override a method, you would need to have code in another method that would do this.
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
It's not quite true. You can, and in fact, you must, call a constructor of an abstract class, from a subclass' constructor.


Tony Morris
Java Q&A (FAQ, Trivia)
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Arnb --

You posted a couple of these today, questions that start with "I just read..." My advice to you (if these are all coming from the same source) is that you don't read this particular book, tutorial, or study guide any further. Wherever these quotes are coming from, you're getting a lot of bad information.


[Jess in Action][AskingGoodQuestions]
Dave Kairys
Ranch Hand

Joined: Sep 09, 2005
Posts: 33
Tony,
What did you mean by
It's not quite true.

I am new to Java and I was referencing the Head First Java text when I provided some insight into the proposed question. Please elaborate on your comment.

Thanks!
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
Arnb Sen
Ranch Hand

Joined: Feb 23, 2004
Posts: 145
Hi Ernest,

I agree with you. I was actually looking for some certification book which explains or describes as the Java Objectives for SCJP.

Any book in which the chapters or the sections are kind of exact replica of the order in which the Objectives are mentioned in Sun's SCJP requirement ?
Arnb Sen
Ranch Hand

Joined: Feb 23, 2004
Posts: 145
Any certification book which follows a similar organisation of the chapters and sections same as that of the SCJP Objective ?
Arnb Sen
Ranch Hand

Joined: Feb 23, 2004
Posts: 145
Have heard that Kathy Sierra's book is very good and helpful. Does that follow similar SCJP Objective structure ?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Abstract classes - instantiation