Karnataka II PUC Computer Science (KSEAB) study materials
Karnataka II PUC Computer Science (KSEAB) study resources

Karnataka II PUC Computer Science (KSEAB): Object-Oriented Concepts and Introduction to C++

Karnataka II PUC Computer Science (KSEAB) · Work through your exam, one topic at a time.

All guide sections

Object-Oriented Concepts and Introduction to C++

Object-Oriented Concepts and Introduction to C++

This domain tests the OOP pillars and the structure of a C++ program. OOP organizes software as classes and objects. A class is a blueprint; an object is an instance with state (data members) and behaviour (member functions).

Pillars

  • Encapsulation: wrapping data and functions; data hiding restricts direct access.
  • Abstraction: exposing essential features and hiding implementation.
  • Inheritance: deriving a new class from an existing one (is-a relationship).
  • Polymorphism: one interface, many forms; compile-time via overloading, run-time via virtual functions. Procedural programming emphasizes functions and global data; OOP emphasizes objects and message passing.

C++ program structure

#include <iostream> brings input/output declarations; using namespace std; lets you write cout without std::; int main() is the entry point; statements end with semicolons; cout << inserts data into the output stream and cin >> extracts input. Comments are // or block comments.

Worked example

#include <iostream> using namespace std; int main() { cout << 2025; return 0; } The preprocessor includes the header, main returns 0 to the operating system, and cout sends 2025 to standard output. No class is defined yet, but this is a valid C++ program.

Traps

C++ is case-sensitive: Main is not main. Do not put a semicolon after #include. OOP is not only classes; encapsulation and data hiding are related but not identical. cout uses <<, not >>.