Object Oriented Programming System (OOPs) Lecture Flashcards

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/29

flashcard set

Earn XP

Description and Tags

Flashcards based on the lecture transcript covering core OOPs principles, access modifiers, constructors/destructors, inheritance, polymorphism, abstraction, static members, and language-specific details for C++ and Java.

Last updated 7:02 AM on 8/29/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

30 Terms

1
New cards

What is Object-Oriented Programming (OOP)?

OOP is a programming paradigm based on the concept of objects, which contain both data (fields or attributes) and code (methods or procedures) to manipulate that data.

2
New cards

What core problems in procedural code does Object-Oriented Programming address?

OOP addresses the lack of clear modular structure (via classes), poor code reuse (via inheritance), insecure data (via encapsulation), difficulty in managing large codebases (via abstraction), and difficulty in modeling real-world entities.

3
New cards

What is the difference between a class and an object?

A class is a blueprint or template defining the structure and behavior (data and functions) of objects, whereas an object is a real-world entity or instance of a class created in memory.

4
New cards

How much memory does a class occupy before an object is created?

A class occupies zero memory until an object is created, as memory is allocated for instances, not the class blueprint itself (except for static members).

5
New cards

What is the size of an empty class in C++?

The size of an empty class in C++ is 1 byte, which ensures that each object has a unique memory address.

6
New cards

What are the three access specifiers in C++ and how do they differ?

Private members are accessible only inside the class; protected members are accessible inside the class and by derived classes; public members are accessible to everyone.

7
New cards

In Java, which access level allows visibility to the class, package, and subclasses, but not to the world?

Protected access modifier.

8
New cards

What is a Friend Class in C++?

A friend class in C++ is a class granted special access to directly access the private and protected members of another class.

9
New cards

What is Encapsulation?

Encapsulation is the wrapping of data (attributes) and methods into a single unit called a class, and restricting direct access to internal data using private access modifiers.

10
New cards

What is a constructor and when is it executed?

A constructor is a special method with the same name as the class and no return type that is automatically invoked once at the time of object creation to initialize object values.

11
New cards

What are the three types of constructors?

Non-Parameterized (Default) Constructor, Parameterized Constructor, and Copy Constructor.

12
New cards

What is a destructor in C++?

A destructor is a special member function prefixed with ~ that has no parameters or return type, automatically called to free resources when an object goes out of scope or is deleted.

13
New cards

How does Java manage memory cleanup without destructors?

Java uses an automatic Garbage Collector that identifies and removes unreachable objects from memory to reclaim space and prevent memory leaks.

14
New cards

What are three common use cases for the Scope Resolution Operator (::) in C++?

Accessing a global variable when a local variable shadows it, defining class functions outside the class, and accessing members within namespaces.

15
New cards

What is the 'this' pointer/reference and where is it available?

It is a pointer (C++) or reference (Java) referring to the current object whose method or constructor is executing; it is available only inside non-static member functions.

16
New cards

What is the difference between a Shallow Copy and a Deep Copy?

A Shallow Copy copies memory references/addresses so objects share dynamic memory (modifying one affects the other), while a Deep Copy allocates new memory and copies actual values so objects remain independent.

17
New cards

What happens to base class public and protected members under Private Inheritance in C++?

Both public and protected members of the base class become private members in the derived class.

18
New cards

Are private members of a base class inherited by a derived class in C++?

Private members are not directly accessible in the derived class, but they still exist in the base class portion of the derived object.

19
New cards

What is the Diamond Problem in multiple inheritance?

It is an ambiguity issue occurring when a derived class inherits from two classes that share a common base class, making it unclear which parent copy of the base member should be accessed.

20
New cards

How is the Diamond Problem resolved in C++?

By using Virtual Inheritance (e.g., class B : virtual public A) so that only a single shared copy of the base class is inherited.

21
New cards

Why does Java not encounter the Diamond Problem with classes?

Java does not support multiple inheritance using classes; it only supports multiple inheritance through interfaces.

22
New cards

What is Compile-time Polymorphism (Static Binding) and how is it achieved?

It is when the method to execute is determined at compile time based on signature; it is achieved via Method/Function Overloading (Java & C++) and Operator Overloading (C++ only).

23
New cards

What are the main rules for Method Overloading?

The method name must be the same, parameters must differ in number, type, or order, and varying the return type alone does not constitute overloading.

24
New cards

What is Run-time Polymorphism (Dynamic Binding) and how is it achieved?

It is when the method to execute is determined at runtime based on the actual object type; it is achieved via Method Overriding using base class pointers/references and virtual functions.

25
New cards

What is a Virtual Function in C++?

A base class member function declared with the 'virtual' keyword, instructing the compiler to use dynamic (late) binding so the correct overridden derived method is invoked at runtime.

26
New cards

What happens in C++ if a derived object is deleted using a base pointer without a virtual destructor in the base class?

Only the base class destructor is invoked, leading to undefined behavior and potential memory leaks.

27
New cards

How is an Abstract Class defined in C++?

An abstract class in C++ is a class that contains at least one Pure Virtual Function (declared with = 0) and cannot be instantiated.

28
New cards

What are three key differences between Abstract Classes and Interfaces in Java?

1) Abstract classes use 'extends' (single class) while interfaces use 'implements' (multiple interfaces allowed); 2) Abstract classes can have constructors, while interfaces cannot; 3) Abstract class fields can be instance/static with any modifier, while interface fields are strictly public static final.

29
New cards

What is a Static Data Member?

A static data member is a variable shared across all objects of a class that is allocated only once in memory and exists even before any object is created.

30
New cards

What is the key restriction on Static Member Functions?

Static member functions belong to the class and can be invoked without creating an object, but they can only directly access static data members and static functions.