Final Practical File-Grade 12
Final Practical File-Grade 12
BANNERGHATTA
2023-24
PRACTICAL FILE
(Subject-Computer Science)
7-stop
OUTPUT FOR THE ABOVE PROGRAM-
VDT TABLE:-
PROGRAM:- 2-
STRING BUFFER PROFRAM USING THE FUNCTION
APPEND
1-initialize a StringBuffer object to create a mutable character sequence.
7-stop
VDT TABLE-
PROGRAM:- 3-
USING STRINGBUFFER PROGRAM:- USING INSERT
FUNCTION
PROGRAM:-- 4
PROGRAM:- TO USE RECCURSION PROGRAM:-
USING THE CONCEPT OF TOWER OF HANOI
PROGRAM:--
OUTPUT FOR THE ABOVE PROGRAM-
VDT TABLE-
PROGRAM:- 5
OUTPUT FOR THE ABOVE PROGRAM-
VDT TABLE-
PROGRAM:- 6
WRITE A PROGRAM:- USING THE CLASS
NAME OF EMPLOYEE AND USING THE
FUNCTION OF INHERTICANCE
1. Define a base class employee with fields ( name) and methods and ).
2. Create a derived class Dog that inherits from Animal. The Dog class adds a new
method
3. In the employee constructor, use super(name) to call the constructor of the
superclass employee and initialize the name field.
4. In the main method, create objects of both the base and derived classes
employee
5. Use methods from both the base and derived classes on their respective
objects. This demonstrates how the derived class inherits the methods and
fields from the base class and can also have its own specialized methods.
OUTPUT FOR THE ABOVE PROGRAM-
VDT TABLE-
PROGRAM:- 7
WRITE A PROGRAM:- USING THE CLASS
NAME OF SALARY AND USING THE
FUNCTION OF INHERTICANCE
Define a base class Employee with fields ( name and baseSalary) and a method
calculateSalary() that calculates the salary based on the base salary.
1. Create a derived class Manager that inherits from Employee. The Manager class
adds a new field bonus and overrides the calculateSalary() method to include the
bonus.
2. In the Manager constructor, use super(name, baseSalary) to call the constructor of
the superclass ( Employee) and initialize the name and base salary fields.
3. In the main method, create objects of both the base and derived classes
(employee and manager).
4. Calculate and print the salaries for both employees using their respective
calculateSalary() methods. This demonstrates how the derived class can override
methods from the base class to provide specialized behavior.
OUTPUT FOR THE ABOVE PROGRAM-
PROGRAM:- 8
WRITE A PROGRAM:- USING THE
CONCEPT OF INHERITANCE
OUTPUT FOR THE ABOVE PROGRAM-
VDT TABLE-
PROGRAM:--9
OUTPUT FOR THE ABOVE PROGRAM-
VDT TABLE-
->PROGRAM:- 10-
Write a PROGRAM:- using recursive
function and display the OUTPUT FOR THE
ABOVE PROGRAM
VDT TABLE-
->PROGRAM:- 12
WRITE A PROGRAM:- USING THE CONCEPT OF
POLYMORPHISM
1. These methods are overloaded because they have the same name ( add) but
different parameter lists.
2. In the main method, we create an instance of the Calculator class and call each
version of the add method with different argument types.
VDT TABLE
PROGRAM:- 15
Algorithm
PROGRAM:--
VDT TABLE
PROGRAM:- 16-
Algorithm
VDT TABLE-
PROGRAM:- 17: Arrays
Algorithm:
cssCopy code
1 . Initialize a variable sum to 0 . 2 . Iterate through each element of the array. a . Add the current element to
the sum. 3 . Print the sum.
Variable Description
PROGRAM:-18 : Inheritance
Description: Create a base class Shape and derive two classes Circle and Rectangle
from it. Implement inheritance concepts.
Algorithm:
sqlCopy code
1. Define the base class Shape with properties and methods. 2. Create the Circle class inheriting from
Shape. 3. Create the Rectangle class inheriting from Shape. 4. Implement methods in the derived classes. 5.
Create objects of both derived classes and demonstrate inheritance.
Algorithm:
kotlinCopy code
1. Define a base class with a method . 2. Create derived classes that override the method. 3. Demonstrate
polymorphism by calling the method on objects of derived classes.
Algorithm:
cssCopy code
1 . Initialize an array to hold stack elements and a variable top to track the top element. 2 . Implement push
and pop operations using array manipulation. 3 . Perform various stack operations (push, pop, peek).
Variable Description