You are on page 1of 43

VIBGYOR HIGH SCHOOL

BANNERGHATTA
2023-24

Grade-12 (ISC Board)

PRACTICAL FILE
(Subject-Computer Science)

MADE BY-WRICK MAJUMDAR


CLASS-12 A
ACKNOLEDGEMENT
I would like to express my special thanks of gratitude
to my Computer teacher Ms Baishali Sen for her able
guidance to support me in completing this project

I would also like to extend my gratidue to my principal


Dr Flora David for providing me with all the facility
that was required
INDEX PAGE
S.NO TOPIC PAGE NO.
1 PROGRAM:- TO FIND SUM AND AVERAGE 1
2 PROGRAM:- FOR FUNCTION OVERLOADING 2
3 PROGRAM:- TO SEARCH AN ELEMENT IN AN ARRAY 3
4 PROGRAM:- TO SEACH A NUMBER IN SINGLE 4
DIMENSIONAL ARRAY
5 PROGRAM:- TO SEARCH A NUMBER IN A DOUBLE 5
DIMENSIONAL ARRAY
6 PROGRAM:- TO FIND THE REVERSE OF A STRING 6
7 PROGRAM:- TO FIND THE FREQUENCY OF 7
CHARECTERS
8 PROGRAM:- TO FILE HANDLE IN JAVA 8
9 PROGRAM:- WRITING TO A FILE 9
10 PROGRAM:- TO FIND THE FACTORIAL OF A NUMBER 10
11 PROGRAM:- TO DO FIBONACCI SERIES 11

12 PROGRAM:- TO PRINT A PATTER ON CONSOLE 12


13 PROGRAM:- TO PRINT A DOUBLE PATTERN 13
14 PROGRAM:- TO BULD A CHARACTER TRIANGLE OF 14
CHARECTERS
15 PROGRAM:- TO FIND THE NTH PRIME NUMBER 15
PROGRAM:-s for practical file
consisting VDT TABLE and
algorithms
1-PROGRAM:- for StringBuffer
1-initialize a StringBuffer object to create a mutable character sequence.

2-Insert Data at a Specific Position:


 Use the insert() method to insert data at a specific position in the StringBuffer.
3-Use the length() method to retrieve the current length of the StringBuffer.

4-Use the charAt() method to access characters at specific indices.

5-Use the replace()

6-Use the setlength()

7-stop
OUTPUT FOR THE ABOVE PROGRAM-

VDT TABLE
Variable method Description
Sb.append(str) Appends the string
Sb.insert(index,str) Inserts the string at
specified index

PROGRAM:- 2-
STRING BUFFER PROFRAM USING THE FUNCTION
APPEND
1-initialize a StringBuffer object to create a mutable character sequence.

2-Insert Data at a Specific Position:


 Use the insert() method to insert data at a specific position in the StringBuffer.
3-Use the length() method to retrieve the current length of the StringBuffer.
4-Use the charAt() method to access characters at specific indices.

5-Use the replace()

6-Use the setlength()

7-stop

OUTPUT FOR THE ABOVE PROGRAM-

VDT TABLE
Variable method Description
Sb.append(str) Appends the string
Sb.insert(index,str) Inserts the string at
specified index
PROGRAM:- 3-
USING STRINGBUFFER PROGRAM:- USING INSERT
FUNCTION

OUTPUT FOR THE ABOVE PROGRAM-

VARIABLE METHOD DESCRIPTION


INSERT(INT OFFSET Inserts a portion of the
charsequence
Insert(char[] data,int Insets a portion of the
start,int end character array data
from start to end
Insert(int Inserts a charsequnce
offset,charsequence s)

PROGRAM:-- 4
PROGRAM:- TO USE RECCURSION PROGRAM:-
USING THE CONCEPT OF TOWER OF HANOI

PROGRAM:--
OUTPUT FOR THE ABOVE PROGRAM-

VDT TABLE-
VARIABLE METHOD DESCRIPTION
Main method Where the tower of
Hanoi problem is
initiated
String destination The name of destination
peg
Int nt The array
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-

VARIABLE METHOD DESCRIPTION


INSERT(INT OFFSET Inserts a portion of the
charsequence
Insert(char[] data,int Insets a portion of the
start,int end character array data
from start to end
Insert(int Inserts a charsequnce
offset,charsequence s)

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
Variable method Description
Sb.append(str) Appends the string
Sb.insert(index,str) Inserts the string at
specified index
->PROGRAM:- 10-
Write a PROGRAM:- using recursive
function and display the OUTPUT FOR THE
ABOVE PROGRAM

1. Define the Base Case(s):


 Determine when to stop the recursion. These are the simplest cases
where the function returns a specific value or performs a specific action.
2. Invoke the Recursive Function:
 In the function body, call the function itself with modified arguments to
solve a simpler or smaller instance of the problem.
3. Combine Results (if necessary):
 If the problem involves combining results from recursive calls, specify
how to combine them to solve the current instance of the problem.
4. Return the Final Result:
 When the base case is met or a simple instance is solved, return the
result.
5. Use the Recursive Function:
 In the main PROGRAM:- or calling context, invoke the recursive
function with initial arguments.
->OUTPUT FOR THE ABOVE PROGRAM
VDT TABLE-

description
Variable method
Recursive case Calls the function
itself
If condition A condition that
checks wheather the
problem can be
solved directly
->PROGRAM:- 11

1. Base Case: If n is 0 or 1, return n because the Fibonacci sequence starts with 0


and 1.
2. Recursive Case: If n is greater than 1, calculate the n-th Fibonacci number by
adding the (n-1)-th and (n-2)-th Fibonacci numbers.
3. In the main method, a loop iterates from 0 to n-1, calling the fibonacci function
for each value and printing the result.
OUTPUT FOR THE ABOVE PROGRAM

VDT TABLE-

Variable method description


Int i A loop counter for
iterating through the
terms of series
Fibonacci series Initializing the first
term of series
For loop A loop to calculate
the remaining terms
of the series

->PROGRAM:- 12
WRITE A PROGRAM:- USING THE CONCEPT OF
POLYMORPHISM
->OUTPUT FOR THE ABOVE PROGRAM

VDT TABLE-
Variable method description
myAnimal=new cat() Assigning an instance
of a different subclass
to the same
reference
Class animal A reference variable
of the superclass type
that can hold objects
of the superclass
->PROGRAM:- 13
->Write a PROGRAM:- using function
overloading

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.
->OUTPUT FOR THE ABOVE PROGRAM-

VDT TABLE-
Variable method description
Int x An integer parameter
for one version of the
mymethod method
Double y A double parameter
for another version of
the “mymethod”
method
String s A string parameter
for yet another
version of mymethod
PROGRAM:- 14-
->WRITE A PROGRAM:- USING FUNCTION
OVEERIDING
OUTPUT FOR THE ABOVE PROGRAM-

VDT TABLE
PROGRAM:- 15
Algorithm

PROGRAM:--
VDT TABLE

Variable method description


New stack Reating new stack
instance
Stack.pop Removing and
returning the top
element
Stack.peek Viewing the top
elemets from the top

PROGRAM:- 16-
Algorithm
VDT TABLE-
PROGRAM:- 17: Arrays

Title: Sum of Array Elements

Description: Write a Java PROGRAM:- to calculate the sum of all elements in an


integer array.

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 Table:

Variable Description

array Integer array to be summed

sum Stores the sum of elements


Variable Description

PROGRAM:-18 : Inheritance

Title: Inheritance Example

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.

Variable Description Table:

 Variables specific to each class (e.g., radius, length, width)

PROGRAM:- 19: Polymorphism

Title: Polymorphism Example

Description: Implement polymorphism by creating a base class and derived classes


with overridden methods.

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.

Variable Description Table:

 Variables specific to each class (if applicable)


PROGRAM:- 20: Stack

Title: Stack Implementation

Description: Implement a stack data structure using arrays.

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).

vatiable description
stack Array to hold stack
data
top Index of the top
element

You might also like