newbie question: Extends and implements

J

Jacky Luk

I have been programming with VC++ for many years. Now I would like to extend
my knowledge to Java. I'd like to know what "Extends" and "Implements"
keywords in the class declaration do... Thanks in advance
Jack
 
L

Luc The Perverse

Jacky Luk said:
I have been programming with VC++ for many years. Now I would like to
extend my knowledge to Java. I'd like to know what "Extends" and
"Implements" keywords in the class declaration do... Thanks in advance
Jack

Extends is just standard class inheritance.

Implements is similar, but only abstract functions can be derived (no
attributes.)

This question seems to be jumping into the middle, however. I suggest you
get a Java book and start from the beginning. If you all ready know how to
program, you should be able to go very quickly through any tutorial or book.
 
J

Jacky Luk

Thank you so much
Jack

Luc The Perverse said:
Extends is just standard class inheritance.

Implements is similar, but only abstract functions can be derived (no
attributes.)

This question seems to be jumping into the middle, however. I suggest you
get a Java book and start from the beginning. If you all ready know how
to program, you should be able to go very quickly through any tutorial or
book.
 
R

Roedy Green

I have been programming with VC++ for many years. Now I would like to extend
my knowledge to Java. I'd like to know what "Extends" and "Implements"
keywords in the class declaration do... Thanks in advance
see http://mindprod.com/gettingstarted.html

You will need a text book for that. Read a text first before posting
any more questions, or you will find people refusing to answer you
later when you ask questions not in every elementary textbook.
 
B

Bhupendra

extends:-
in java extends keyword is used for inheritence from only one class

example

public class demo extends Frame \\\legal declaration
{ ......... }

public class demo extends Frame, Applet \\\illegal declaration
{ ......... }

implementation Keyword: -

The implements keyword is used for multiple inheritence in java, but
you can only implement only interface (which same as like abstract
classes in C++ but only difference is here that no methods should have
body in interface.

example:

inteface demoInterface1
{
public void demoMethod(int demoVar);
}

inteface demoInterface2
{
public void demoMethod(int demoVar);
}

public class demo extends Frame implements demoInterface1,
demoInterface2
{.................................}

Here you are extending Frame class and implementing multiple interface
demoInteface1, demoInteface2 but the methods body of the the interface
methods will be written in class where the inteface has been
implemented.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,433
Messages
2,571,683
Members
48,796
Latest member
Greg L.

Latest Threads

Top