Lab Sheet: Unit 3 – Tokens,
Expressions and Control Structures
Lab Sheet – Short Practice Programs
Lab 1: Simple Class and Object
Write a program to define a class Book with attributes: title, author, price. Create and
display details of two objects.
Lab 2: Constructors
Create a class Circle with radius and area. Use both default and parameterized constructors
to initialize values.
Lab 3: Method Overloading
Write a class Calculator that has overloaded methods add(int, int) and add(double, double).
Lab 4: Using this Keyword
Create a class Employee with a constructor using this keyword to initialize data members
when parameter names conflict.
Lab 5: Access Control
Define a class with public, private, and protected members. Try accessing them from
another class to demonstrate visibility.
Lab 6: Recursion
Write a recursive function to calculate the factorial of a number.
Lab 7: Nested and Inner Class
Create a class Outer with a nested class Inner that accesses a private field of the outer class.