CS6461-Oops Lab Manual
CS6461-Oops Lab Manual
CS6461
Student Name:
Registration
Number:
Year/Sec:
INCHARGE SIGNATURE
PAGE
EXP.NO TITLE DATE SIGN
NO
.
Object Oriented Programming Lab Manual CS6461
INDEX
C++ Programs
1. A. Functions with default arguments
1. B. Call by value, call by reference and call by address
2. A. Classes and objects
.
Object Oriented Programming Lab Manual CS6461
Java Programs
6. A. Class and object in java
6. B. Strings in java
7. Packages in java
8. Interfaces in java
9. A. Threads in java
9. B. Multithreading
10. A. Exception handling
10. B. User defined exception
C ++ PROGRAMS
1 To Write a C++ program using functions to
a) Implement function overloading and default arguments.
b) Implement call by value, call by address and call by reference.
2 To write a C++ program to implement simple classes for understanding objects,
member functions & constructors.
a) classes with primitive data members
b) classes with arrays as data members
c) classes with pointers as data members
d) classes with constant data members
.
Object Oriented Programming Lab Manual CS6461
JAVA PROGRAMS
To write a Simple Java application program for
6 a) Understanding references to an instant of a class.
b) Handling strings in Java.
To write a java program to
7 a) Create simple package creation.
3 To develop a java program to read and sort the contents of the file.
.
Object Oriented Programming Lab Manual CS6461
Aim:
To write a C++ program to implement function overloading and use default arguments.
Algorithm:
Function Overloading
.
Object Oriented Programming Lab Manual CS6461
Default Arguments
Aim:
To write a C++ program using functions to implement call by value, call by address
and call by reference
Algorithm:
.
Object Oriented Programming Lab Manual CS6461
Aim:
To write a C++ program to implement classes and objects.
Algorithm:
.
Object Oriented Programming Lab Manual CS6461
Aim:
Algorithm:
1. Start the program.
2. Declare the class name as Stat with data member s and member functions.
3. The constructor Stat() which is used to increment the value of count as 1 to to assign
the variable code.
4. The function showcode() to display the code value.
5. The function showcount() to display the count value.
.
Object Oriented Programming Lab Manual CS6461
Aim:
Algorithm:
1. Operator Overloading
2. Start the Program.
3. Declare a class as complex with real and imaginary part as data members
4. Define constructor overloading to assign different value for complex data member
5. Define member function getdata () to get the value of complex no
.
Object Oriented Programming Lab Manual CS6461
Aim:
Algorithm:
1. Start the program.
2. Declare the prototypes for volume function to find volume of cube, cylinder, and rectangle.
3. Get the input values such as side, length, breadth, height, and radius.
4. Invoke volume function of cylinder by passing radius and height to find volume of cylinder.
5. Invoke volume function of cube by passing side of cube to find volume of cube.
6. Invoke volume function of Rectangle by passing length, breadth and height to find volume
. of rectangle.
7. Print the volume of cube, cylinder and rectangle
.
Object Oriented Programming Lab Manual CS6461
AIM:
To calculate the total mark of a student using the concept of inheritance and virtual
base class.
ALGORITHM:
Aim:
To write a C++ program to implement run time polymorphism through virtual function.
Algorithm:
1. Start the program
2. Declare a base and define display () member function to display base class content.
define show() member function to show base class content.
3. Declare a derived class inherit from base and define display () member function to
display derived class content. Define show () member function to derived class content.
4. In main function create object for base and derived class.
5. Assign base ptr to base class object.
6. Invoke display function of base class using base pointer variable
.
Object Oriented Programming Lab Manual CS6461
Aim:
Algorithm:
1. Start the program.
2. Create a class template. Template <class T >
3. Create a class with data member and functions.
4. Create object and call the template class by defining data types.
.
Object Oriented Programming Lab Manual CS6461
Aim:
To write a C++ program for creating student data using sequential file access.
Algorithm:
1. Start the program
2. Define student class and create the function get and show.
3. Use ofstream and ifstream get and display the file information.
4. Invoke function using sequential file access.
5. Display the output
6. Stop the program
.
Object Oriented Programming Lab Manual CS6461
Aim:
To write a C++ program for creating student data using random file access.
Algorithm:
.
Object Oriented Programming Lab Manual CS6461
Aim:
To write a java to implement class and object
Algorithm:
1. Start the program.
2. Write try, catch and throw blocks.
3. If an exception occurs in try block, then detect and throw an exception
4. Thrown exception caught by catch block and the exception is printed.
5. Print the RESULT.
6. Stop the program
.
Object Oriented Programming Lab Manual CS6461
Aim:
Algorithm:
.
Object Oriented Programming Lab Manual CS6461
Aim:
T o create a package in java and import the user defined package in a current
application.
Algorithm:
2. Create the package as mypackage and define a class called balance which consist
of two data members account holder name and balance
.
Object Oriented Programming Lab Manual CS6461
4. Import the package in new class called as test balance which consist of main function
Aim:
T o write a java program to find area of circle and volume of a cylinder using interfaces
and inheritance in Java
Algorithm:
.
Object Oriented Programming Lab Manual CS6461
3. Create the interface name as area and declare variables and methods in interface
4. Define class cylinder and the class circle which implements the interface area,
volume and define member function compute () for each class to compute area
of circle and volume of the cylinder.
5. Create a class called interfacetest define main function and Create object for
cylinder and circle
6. Create object for interface
7. Assign circle object to interface object and call compute function of circle to find area
of circle.
8. Display the RESULT.
9. Stop the program.
Aim:
Algorithm:
Aim:
Algorithm:
Aim:
Algorithm:
.
Object Oriented Programming Lab Manual CS6461
Aim:
Algorithm:
.
Object Oriented Programming Lab Manual CS6461
Aim:
To write a C++ program for getting the input using the function getline ( ) and display
the output using function write ( ).
Algorithm:
.
Object Oriented Programming Lab Manual CS6461
Aim:
To write a C++ program to read the content of a file.
Algorithm:
1. Start the program.
2. Declare the variables.
3. Get the file name to read.
4. Using ifstreamin (filename) check whether the file exist.
5. If the file exist then check for the end of file condition.
6. Read the contents of the file.
.
Object Oriented Programming Lab Manual CS6461
Aim:
To write a java program to read and sort the contents of the file.
Algorithm:
.
Object Oriented Programming Lab Manual CS6461