0% found this document useful (0 votes)
10 views1 page

Uni 3 Lab

The document outlines a lab sheet for Unit 3 focusing on tokens, expressions, and control structures through various programming exercises. It includes tasks such as creating classes with attributes, using constructors, method overloading, employing the 'this' keyword, demonstrating access control, implementing recursion, and working with nested and inner classes. Each lab aims to reinforce fundamental programming concepts in object-oriented design.

Uploaded by

twinklestar9817
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 views1 page

Uni 3 Lab

The document outlines a lab sheet for Unit 3 focusing on tokens, expressions, and control structures through various programming exercises. It includes tasks such as creating classes with attributes, using constructors, method overloading, employing the 'this' keyword, demonstrating access control, implementing recursion, and working with nested and inner classes. Each lab aims to reinforce fundamental programming concepts in object-oriented design.

Uploaded by

twinklestar9817
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

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.

You might also like