Professional Documents
Culture Documents
Oop Assignment 1
Oop Assignment 1
CLASS DEFINITION:
C++:
A class is initiated in C++ using keyword “class” followed by the
name of class. The body of class is declared inside the curly braces and
terminated by a semicolon at the end. You can declare an objects, when
a class is defined, only the specification for the object is defined, no
memory or storage is allocated.
JAVA:
A class--the basic building block of an object-oriented language
such as Java--is a language that describes the data and behavior
associated with instances of that class. When you initiate a class, you
create an object that looks and feels like other instances of the
same class.
OBJECT CREATION:
C++:
In C++, object is a real-world entity, for example, chair, car, pen,
mobile, laptop etc. In other words, object is an entity that has state and
behavior. Here, state means data and behavior means
functionality. Object is a runtime entity; it is created at runtime.
JAVA:
A Java object is a combination of data and procedures working
on the available data. An object has a state and behavior. The state of
an object is stored in fields (variables), while methods (functions)
display the object's behavior. Objects are created from templates known
as classes.
ABSTRACTION:
C++:
Abstraction means displaying only essential information and
hiding the details. Data abstraction refers to providing only essential
information about the data to the outside world, hiding the background
details or implementation. ... Abstraction using Classes: We can
implement Abstraction in C++ using classes.
JAVA:
In Java, abstraction is achieved using Abstract classes and
interfaces.
ENCAPSULATION:
C++:
JAVA:
C++:
JAVA: