카테고리 없음

C++ 면접 질문 & 객체지향프로그래밍 면접 질문

minjiwoo 2022. 2. 5. 19:43
728x90

What is the OOP ?

: OOP is the creation of objects that has both data and functions. 

 

What is the principle of OOP ?

: Abstraction, Encapsulation, Inheritance and Polymorphism. 

 

What is an Object ?

Objects has data and instructions to act on that data. 

 

What is class ?

: Class is like a template. Blueprint for an object. 

It is a user-defined data type, which holds its own data members and member functions which can be accessed and used by an instance of that class. 

It has different components of a class.

1. Public : The class members can be accessed from everywhere. 

2. Private : The class members can only be accessed by the defining class. 

3. Protected : The class memeberes can only be accessed by parent and interited classes. 

 

What is Encapsulation ?

It is a group of properties and members under a single class or object. Programs can be really long and there can easily be a ton of moving parts in it. After some time it gets really tough to maintain all these objects without them running into complexity. 

We can encapsulate a set of objects into different classes. We can prevent the repitition of code and also shorten the length of your code. 

 

What is Inheritance ?

It is the ability to acquire the properties of existing classes and create new ones. Inheritance allows you to reuse code.

 

What is polymorphism ?

Polymorphism referes to one name with many forms. It is the ability of one function to perfom in different ways. 

What is Method Overloading ?

When a class has multiple methods with the same names but a different set of parameters. 

What is Method Overriding ?

this is only possible for subclass has the same method as the parent class. 

RULE : same parameter list, same return type, have more restrictive modifier than that of the parent class. 

 

 

What is Method Overriding

https://www.partech.nl/en/publications/2020/10/basic-principles-of-object-oriented-programming#

 

Basic Principles of Object-Oriented Programming

 

www.partech.nl

 

728x90