0% found this document useful (0 votes)
10 views2 pages

Computer Science C M M Questions

The document discusses object-oriented programming concepts like classes, objects, access specifiers, constructors and member functions. It explains that classes are blueprints for objects, and objects are instances of classes. Access specifiers like public, private and protected determine object accessibility. Constructors initialize object values and are executed during object creation, but are not mandatory.

Uploaded by

mediallounge
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

Computer Science C M M Questions

The document discusses object-oriented programming concepts like classes, objects, access specifiers, constructors and member functions. It explains that classes are blueprints for objects, and objects are instances of classes. Access specifiers like public, private and protected determine object accessibility. Constructors initialize object values and are executed during object creation, but are not mandatory.

Uploaded by

mediallounge
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

3/10/2023

Computer Science – C++


Assignment 3

 What is Object-Oriented Programming? List its Characteristics.


Object-Oriented Programming (OOP) is a programming pattern that is built around objects or entities.
Object-Oriented Programming is a computer programming model that organizes software design around
data or objects, rather than functions and logic. Characteristics of OOP are. Object Oriented Programming
refers to a language that uses objects in programming. OOP aims to implement real-world entities like
inheritance, hiding, polymorphisms, etc. in programming.
1. Class
2. Object
3. Abstraction
4. Encapsulation
5. Polymorphism
6. Inheritance

 What are classes and Objects? How does it accomplish data hiding?
Class is a blueprint and object is instance of a class. Class is a user-defined data type, which holds
its own data members and member functions and helps in code reusability. An Object is an
instance of a class. When a class is defined no memory is allocated but when the object is created
memory is allocated. An object has an identity, state and behavior which each object contains data
and code to manipulate the data.

 Explain the use of the access specifiers “private”, “protected” and “public” as they relate to data
members.
1. Public access specifier – members are accessible from outside of the class. All the class
members declared under the public specifier will be available to everyone. The data members
and member functions declared as public can be accessed by other classes and functions too.
2. Private access specifiers – members cannot be accessed or viewed from outside the class. The
class members declared as private can only be accessed within the class itself by the member
functions. They are not allowed to be accessed directly by any other object or function
outside the class. Only the member function that are allowed to access the private data
members of the class.
3. Protected access specifiers – members cannot be accessed from outside the class, but they can
be accessed within the inherited class. The protect access specifier is similar to the private
access specifier in terms as it cannot be accessed outside of its class, but the difference is that
the class members declared as protected can be accessed by any subclass of that class as well,
 Give any two differences between Normal member function and Constructor.
1. A construction does not have a return type, but a member function does have a return type.
2. Constructors must be named the same as the class name, but member functions should have a
different name than the class name.

 What is Constructor? Is it mandatory to use constructor in a class?


A constructor has special member functions named after its class (without a return type) having
the same name as its class which is used to initialize some values to the data members of an
object. It is executed automatically whenever an object of a class is created.
No, it is not mandatory to use a constructor in a class. It is not required to provide any
constructors for your class. Users do not need to write every constructor within every class.
Although it is required that you must have a constructor with the required access specifier.

You might also like