Many of the articles and books says Java is more object oriented than C++. How? The difference is in Multiple inheritance but i'm not getting it... Friends help me in understanding this concept?
Thanks
Manoj:)
Printable View
Many of the articles and books says Java is more object oriented than C++. How? The difference is in Multiple inheritance but i'm not getting it... Friends help me in understanding this concept?
Thanks
Manoj:)
In c++, you can write a program without class(without using OOPS concept).
But java does not allows to do this. Even the main function should be inside a class.
It insists the OOPS concept.
Manoj,
The reason may be:
In c++, classes are just 'templates' or blue prints for a particular user defined data type. They do not exist as anything else but that.
In java on the other hand, classes are templates ans actual run time artifacts i.e. each class is loaded in to the JVM. Thus the classes exist at runtime and inherit from java.lang.class. This helps to implement and use reflection. You can even use a 'instanceof' operator to check if a given object is instance of class etc.
C++ supports object orientation but is primarily a multi-paradigm language.
Multiple inheritince is a big difference between the two languages too.
C++ allows 'strict multiple inheritence' i.e. inheriting from more than one class. Java does not allow this (you can't extend more than one class). Rather, it simulates multiple inheritence by concept of inheritence (abstractness)
This avoids the famous (or infamous ;)) Diamond of death problem[URL="http://en.wikipedia.org/wiki/Diamond_problem"]http://en.wikipedia.org/wiki/Diamond_problem[/URL]
hello manoj,
This is Jananianandan, you got the same doubt each and every person who would get learning Java,
I believe you know object oriented concepts mean, any way
(See working with real time objects virtually ) using abstraction, encapsulation, inheritance and polymorphism, C++ is purely object oriented, compared to C++ , java is not 100% oops, coz it doesnt support multiple inheritance, multiple inheritance is more than one parent class for a child class, this can be achieved in c++ very easily, but java doesnt support multiple inheritance, bcoz it doesnt have global declaration at all, it ensure the factor of encapsulations very well, and the multiple inheritance can be achieved with the help of interfaces, these interface can't be instantiated,
they have only member declarations and method declarations, The class implementing the interfaces would use all the methods,
Also java doesn't have operator overloading as of c++(++,=),
Next no global declarations allowed, Thats why java isint pure oops based.
I believe i would be clear, if not , please reply me.:)