Solved

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

Posted on 2004-08-26
7
230 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 150 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 100 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
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!

 
LVL 12

Assisted Solution

by:Giant2
Giant2 earned 50 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jdbc error in jsp application 20 74
runtime exception 2 50
How to convert from xls to xlsx using java 7 95
ejb entity bean example issue 2 28
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 This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

730 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