Solved

Class overwritten?

Posted on 2002-05-11
2
297 Views
Last Modified: 2013-11-23
section A)
Consider the following java classes-
GenericServlet class:
public abstract class GenericServlet extends Object implements Servlet, ServletConfig, Serializable.
HttpServlet class:
public abstract class HttpServlet extends GenericServlet implements Serializable.

section B)
Consider my class below:
public class GenericServlet extends HttpServlet.

It is the base class of HttpServlet class as in section A), however, it is again defined to be a sub-class of HttpServlet in B).
Does B) overwrite a class?
Or B) defines a totally new class only?
How is the GenericServlet be interpreted?
0
Comment
Question by:kenchan2000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Expert Comment

by:hogberg78
ID: 7003654
Homework? Think about the packages/namespaces.
0
 
LVL 35

Accepted Solution

by:
girionis earned 50 total points
ID: 7003713
 You cannot have two classes of the same name in the same package. What you have written up there could not be compiled if you were to use it with javac. Two classes can have the same name if they reside in different packages. You would have to give the full name of the package. If you have two GenericServlet classes in different packages (package1.GenericServlet and package2.GenericServlet) then you could do something like:

// GenericServlet in package1
package package1;
public abstract class GenericServlet extends Object implements Servlet, ServletConfig, Serializable.

/ HttpServlet in either package2 or somewhere else.
public abstract class HttpServlet extends package1.GenericServlet implements Serializable

and

// Generic Servlet in package2
package package2;
public class GenericServlet extends HttpServlet.

  Hope it helps.
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Android development question 2 108
Java Restore security prompts not working 10 246
Print Rhino Java Array in Javascript 1 57
batch vs regular insert in spring DAO 2 50
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question