Solved

Class overwritten?

Posted on 2002-05-11
2
296 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to get all the API from website? 11 125
Should localization be done inside spring controller 5 37
jsp login check 12 52
Html Table Looping (part 2) 5 35
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This video teaches viewers about errors in exception handling.

756 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