Results 1 to 4 of 4

Thread: Java over C++

  1. #1
    Expert Member
    Join Date
    Jan 2007
    Answers
    249

    Smile Java over C++

    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


  2. #2
    Expert Member
    Join Date
    Dec 2006
    Answers
    204

    Re: Java over C++

    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.


  3. #3
    Junior Member
    Join Date
    Feb 2007
    Answers
    23

    Re: Java over C++

    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 problemhttp://en.wikipedia.org/wiki/Diamond_problem


  4. #4
    Junior Member
    Join Date
    Feb 2007
    Answers
    4

    Smile Re: Java over C++

    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.


  5.  Sponsored Ads
    Ad


     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact