Solved

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

Posted on 2004-08-26
7
211 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
basic hardware to learn oop advanced design patterns 3 88
Free Alternative to JIRA 4 91
Java array passed to SQL where clause 23 64
Java / Linux and Regular Expressions 11 71
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…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

863 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now