Name: Vansh Nagda Roll no.
: 381 Class: SYIT
MALAD KANDIVALI EDUCATION SOCIETY’S
NAGINDAS KHANDWALA COLLEGE OF COMMERCE, ARTS &
MANAGEMENT STUDIES & SHANTABEN NAGINDAS KHANDWALA
COLLEGE OF SCIENCE
MALAD [W], MUMBAI – 64
AUTONOMOUS INSTITUTION
(Affiliated To University Of Mumbai)
Reaccredited ‘A’ Grade by NAAC | ISO 9001:2015 Certified
CERTIFICATE
Name: VANSH DILIP NAGDA
Roll No: 381 Programme: BSc IT Semester: III
This is certified to be a bonafide record of practical works done by the above student in the
college laboratory for the course Core Java (Course Code:2131UISCJ) for the partial fulfilment of
Third Semester of BSc IT during the academic year 2021-22.
The journal work is the original study work that has been duly approved in the year 2021-22
by the undersigned.
_____________________ ____________________
External Examiner (Ms.Niramaye Deshpande)
(Subject-In-Charge)
Date of Examination: (College Stamp)
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Sr.No. Date Topic Page No
1 1-7-21 Java Data types: 4-6
a. Write a program to accept length and breadth as
command line arguments and calculate area and
perimeter of rectangle.
b. Write a program to accept integer values for a, b
and c which are coefficients of quadratic equation
and find the solution of quadratic equation.
2 8-7-21 Use of operators: 7 – 15
a. Demonstrate the use of various types of operators
supported by Java.
b. Write a program to reverse a string.
3 15-7-21 16 – 18
Use of Control statements and Iterators :
a. Write a program to find the smallest and largest
element from an array.
b. Write a program to count the letters, spaces,
numbers and other characters of an input string.
4 29-7-21 Using classes and objects : 19 – 22
a. Design a class in java which includes instance
methods and instance variables and initialize them
by creating object.
b. Demonstrate the use of constructors in java.
5 5-8-21 Inheritance : 23 – 30
a. Write a java program to implement single level
inheritance.
b. Write a java program to implement multiple
inheritance.
c. Write a java program to implement multilevel
inheritance.
d. Write a java program to implement hierarchical
inheritance.
Name: Vansh Nagda Roll no.: 381 Class: SYIT
6 12-8-21 Polymorphism : 31 - 33
a. Write a java program to implement method
overloading.
b. Write a java program to implement method
overriding.
7 26-8-21 Packages and Multithreading : 34 – 35
a. Write a java program to implement multithreading.
8 2-9-21 Arrays : 36 – 38
a. Sorting Array elements in Ascending order.
b. Sorting Array elements in descending order.
9 9-9-21 String handling and Exception handling : 39 – 42
a. Demonstrate the use of various methods of String
and StringBuffer class to manipulate strings
b. Demonstrating the use of try catch and finally
block to create and handle
10 16-9-21 I/O streams and File handling : 43 – 44
a. Demonstrating the use of BufferedReader and
Scanner classes for taking user input from
console.
11 23-9-21 AWT : 45 – 54
a. Design an AWT application that contains the
interface to add student information and display
the same.
b. Design a calculator based on AWT application.
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Practical 1 A:- Java Data types
Aim :- A. Write a program to accept length and breadth as command line
arguments and calculate area and perimeter of rectangle.
Theory:- Data types specify the different sizes and values that can be stored
in the variable. There are two types of data types in Java:
Primitive data types: In Java language, primitive data types are the building
blocks of data manipulation. These are the most basic data types available in
Java Language The primitive data types include boolean, char, byte, short, int,
long, float and double.
Non-primitive data types: The non-primitive data types include Classes,
Interfaces and Arrays.
Code: -
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Output: -
Aim :- B. Write a program to accept integer values for a, b and c which are
coefficients of quadratic equation and find the solution of quadratic equation.
Code: -
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Output: -
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Practical 2 :- Use of operator
Aim :- A. Demonstrate the use of various types of operators supported by
Java.
1. Arithmetic operator :-
Theory:- Arithmetic operators are used to perform common
mathematical operations. Some of the Arithmetic operators are:
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Code: -
Output: -
Name: Vansh Nagda Roll no.: 381 Class: SYIT
2. Relational Operator :-
Theory :- relational operators determine if one operand is greater than, less
than, equal to, or not equal to another operand. The majority of these operators
will probably look familiar to you as well. Keep in mind that you must use
"==", not "=", when testing if two primitive values are equal.
== equal to
!= not equal to
> greater than
>= greater than or equal to
< less than
<= less than or equal to
Code: -
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Output: -
3. Logical Operator :- Theory :- Logical operators are used to determine the
logic between variables or values. Some of the Logical Operators are:
Code: -
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Output: -
4. Conditional Operator :-
Theory:- The && and || operators perform Conditional-AND and Conditional- OR
operations on two boolean expressions. These operators exhibit "short- circuiting" behavior,
which means that the second operand is evaluated only if needed.
&& Conditional-AND ||
Conditional-OR
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Code: -
Output: -
5. Instanceof operator :-
Theory:- The instance of operator compares an object to a specified type. You can use it to
test if an object is an instance of a class, an instance of a subclass, or an instance of a class
that implements a particular interface.
Code: -
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Output: -
6. Increment and Decrement operator :-
Theory:- the increment operator ++ increases the value of a variable by 1.
Similarly, the decrement operator -- decreases the value of a variable by 1.
• If you use the ++ operator as a prefix like: ++ var, the value of var
is increment by 1;then it returns the value.
• If you use the ++ operator as a postfix like : var++, the original
value of var is returned first, then var is incremented by 1.
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Code: -
Output: -
Aim: - B. Write a program to reverse a string.
Theory: - Java program to reverse a string that a user inputs. The charAt method is used
to get individual characters from the string, and we append them in reverse order. Code:
-
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Output :-
Practical 3 :- Use of Control statement and Iterators
Aim :- A. Write a Program to find smallest and largest number from
array.
Theory:- Java compiler executes the code from top to bottom. The statements
in the code are executed according to the order in which they appear.
However, Java provides statements that can be used to control the flow of
Java code. Such statements are called control flow statements. It is one of the
fundamental features of Java, which provides a smooth flow of program.
Java provides three types of control flow statements.
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Code: -
Output: -
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Aim :- B . Write a Program to count letters, spaces, numbers, and other
characters of an input string.
Code: -
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Output: -
Practical 4 :- Use of classes and objects
Aim :- A. Design a class in java which includes instance method and instance
variable and initialize them by creating object.
Theory:- A class is a group of objects which have common properties. It is a
template or blueprint from which objects are created. It is a logical entity. It
can't be physical.
An entity that has state and behavior is known as an object e.g., chair, bike,
marker, pen, table, car, etc. It can be physical or logical. Basically, it is an
instance of a class.
An instance variable is a variable which is declared in a class but outside of
constructors, methods, or blocks. Instance variables are created when an object
is instantiated, and are accessible to all the constructors, methods, or blocks in
the class.
Instance method are methods which require an object of its class to be created
before it can be called. To invoke a instance method, we have to create an
Object of the class in within which it defined.
Code: -
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Output: -
Aim: - B . Demonstrating use of constructor in java.
Theory: - Java BufferedReader class is used to read the text from a
characterbased input stream.
Code: -
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Output :-
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Practical 5 :- Inheritance
Aim: -A. Write a java program to implement single level inheritance.
Theory: - Creating subclasses from a single base class.
Code: -
Output: -
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Aim :- B. Write a java program to implement multiple inheritance.
Theory:- Defining derived class from numerous base classes
Code :-
Output :-
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Aim :- C . Write a java program to implement multilevel inheritance.
Theory:- A class extends to another class that is already extended from
another class.
Code :
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Output :-
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Aim :- D. Write a java program to implement hierarchical inheritance.
Theory:- More than one derived class extends a single base class. In
simple words, more than one child class extends a single parent class or a
single parent class has more than one child class.
Code :-
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Output: -
Practical 6 :- Polymorphism
Aim: - A. Write a java program to implement method overloading.
Theory: - If a class has multiple methods having same name but different in
Name: Vansh Nagda Roll no.: 381 Class: SYIT
parameters.
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Output :-
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Aim: - B. Write a program to implement concept of Method overriding in Java.
Theory: - If subclass (child class) has the same method as declared in the parent
class.
Code:
Output :-
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Practical 7 :- Packages and Multithreading
Aim :- Write a java program to implement multithreading.
Theory:- Multithreading in Java is a process of executing multiple threads
simultaneously. A thread is a lightweight sub-process, the smallest unit of
processing. Multiprocessing and multithreading, both are used to achieve
multitasking. Java Multithreading is mostly used in games, animation, etc.
Code :-
Output :-
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Practical 8 :- Arrays
Aim :- A. Sorting Array elements in Ascending order.
Theory:- In this program, we need to sort the given array in ascending order
such that elements will be arranged from smallest to largest. This can be
achieved through two loops. The outer loop will select an element, and inner
loop allows us to compare selected element with rest of the elements.
Code: -
Output :-
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Aim :- B. Sorting Array elements in descending order.
Theory:- In this program, we need to sort the given array in descending
order such that elements will be arranged from largest to smallest. This can
be achieved through two loops. The outer loop will select an element, and
inner loop allows us to compare selected element with rest of the elements.
Code :-
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Output :-
Practical 9 :- String handling and Exception handling
Aim :- A. Demonstrate the use of various methods of String and
StringBuffer class to manipulate strings.
Theory:- String is basically an object that represents sequence of char values.
String class provides a lot of methods to perform operations on strings such as
compare(), concat(), equals(), split(), length(), replace(), compareTo(), intern(),
substring().
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Code :-
Output :-
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Aim :- B. Demonstrating the use of try catch and finally block to create and handle .
Theory:- Exception handling is one that allows us to handle the runtime errors
caused by exceptions. If an exception occurs, which has not been handled by
programmer then program execution gets terminated and a system generated
error message is shown to the user. This message is not user friendly so a user
will not be able to understand what went wrong. In order to let them know the
reason in simple language, we handle exceptions.
Code :-
Output :-
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Practical 10 :- I/O streams and File handling
Aim :- Demonstrating the use of BufferedReader and Scanner classes for
taking user input from console.
Theory :-
BufferedReader :- The BufferedReader class of Java is used to read the stream
of characters from the specified source. This class provides a method named
read() and readLine() which reads and returns the character and next line from
the source (respectively) and returns them.
Scanner :- Scanner is a class in java.util package used for obtaining the input of
the primitive types like int, double, etc. and strings. It is the easiest way to read
input in a Java program. java util package can be imported without downloading
any external libraries. Scanner reads text from standard input and returns it to a
program.
Code :-
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Output :-
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Practical 11 :- AWT
Aim :- A. Design an AWT application that contains the interface to add
student information and display the same.
AWT (Abstract Window Toolkit) is an API to develop Graphical User Interface
(GUI) or windows-based applications in Java.
Java AWT components are platform-dependent i.e. components are displayed
according to the view of operating system. AWT is heavy weight i.e. its
components are using the resources of underlying operating system (OS).
The java.awt package provides classes for AWT API such as TextField,
Label, TextArea, RadioButton, CheckBox, Choice, List etc. Code :-
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Output :-
Aim :- B. Design a calculator based on AWT application.
Name: Vansh Nagda Roll no.: 381 Class: SYIT
AWT (Abstract Window Toolkit) is an API to develop Graphical User Interface
(GUI) or windows-based applications in Java.
Java AWT components are platform-dependent i.e. components are displayed
according to the view of operating system. AWT is heavy weight i.e. its
components are using the resources of underlying operating system (OS).
The java.awt package provides classes for AWT API such as TextField, Label,
TextArea, RadioButton, CheckBox, Choice, List etc.
Code :-
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Name: Vansh Nagda Roll no.: 381 Class: SYIT
Output :-
Output of 7 * 2
Name: Vansh Nagda Roll no.: 381 Class: SYIT