Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Interface (Java) & Abstract Class (C++) ?

Posted on 2004-08-26
7
Medium Priority
?
246 Views
Last Modified: 2012-05-05

 Hi Experts,

    This is actually a follow up question of :
http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21107718.html

  Now I have more idea about interface. Then I am wondering does the "interface" in Java play the same role as the "abstract class" in C++ ?

  Is it true that : " The are multiple (class) inherence in C++, but java can extend only one class. Therefore, the interface actually doing something like "multiple inherence" in C++" ?

   Thanks a lot !!!

 meow.
0
Comment
Question by:meow00
[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
  • 3
  • 2
  • 2
7 Comments
 
LVL 15

Accepted Solution

by:
Javatm earned 600 total points
ID: 11909432
Hi Friend;

The answer to this question that you posted and also this one that you posted :
http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21109221.html

Is in here : http://www.firstsql.com/java/gotchas/

=-) Read that and that should answer your questions !.

Glad to help . . .
Javatm
0
 
LVL 15

Expert Comment

by:Javatm
ID: 11909464
>  Then I am wondering does the "interface" in Java play the same role as the "abstract class" in C++ ?

Answer = True;

> The are multiple (class) inherence in C++, but java can extend only one class.
> Therefore, the interface actually doing something like "multiple inherence" in C++    

Answer = True;

Read the links above for further explanations !

Hope that helps . . .
Javatm    
0
 
LVL 35

Assisted Solution

by:girionis
girionis earned 400 total points
ID: 11910306
>  " The are multiple (class) inherence in C++, but java can extend only one class. Therefore, the
> interface actually doing something like "multiple inherence" in C++" ?

You could say that although this is not strictly true. The point of inheritance is to inherit characteristics from the parent class, i.e. bahaviour or state. An interface does not implement any behaviour (although it can have state through its variables) so you must be very careful when you use the term "multiple inheritance" by using interfaces. A better term would be "multipel interfaces inheritance"

You might also want to take a look here:

http://mindprod.com/jgloss/multipleinheritance.html
http://www.javaworld.com/javaqa/2002-07/02-qa-0719-multinheritance.html
http://www.javaworld.com/javaworld/jw-04-2001/jw-0413-polymorph.html
0
Independent Software Vendors: 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!

 
LVL 12

Assisted Solution

by:Giant2
Giant2 earned 200 total points
ID: 11910506
Interface in Java tell "only" what the classes implementing this interface must implement.
The intent of abstract class is to provide general functionality (taken from MSDN).

Interface in java do not specify any piece of code. It contains the declaration of the methods.
If you want a similarity with C, you can find in some manner about java interface and declaration of the method in C.

And abstract in C is little similar to abstract in java.

Hope this clarify some doubt, Giant.
0
 
LVL 35

Expert Comment

by:girionis
ID: 11912297
:)
0
 
LVL 12

Expert Comment

by:Giant2
ID: 11912316
Thanks.
:)
0
 
LVL 15

Expert Comment

by:Javatm
ID: 11917755
=-) Always glad to help . . .

http://freewebs.com/cube-j
Friend : Javatm
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

618 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