Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
19 views17 pages

Java Practical

The document is a practical submission on Object Oriented Programming using JAVA by Patil Hiral Vasantbhai, supervised by Prof. Bhavesh B. Prajapati at Government MCA College. It outlines the vision, mission, program educational objectives, outcomes, and specific outcomes of the course, along with a comprehensive list of programming tasks and projects to be completed. The submission is part of the MCA curriculum for the academic year 2025-26 at Gujarat Technological University.

Uploaded by

patilhiral1907
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views17 pages

Java Practical

The document is a practical submission on Object Oriented Programming using JAVA by Patil Hiral Vasantbhai, supervised by Prof. Bhavesh B. Prajapati at Government MCA College. It outlines the vision, mission, program educational objectives, outcomes, and specific outcomes of the course, along with a comprehensive list of programming tasks and projects to be completed. The submission is part of the MCA curriculum for the academic year 2025-26 at Gujarat Technological University.

Uploaded by

patilhiral1907
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

A PRACTICAL SUBMISSION

OF

Object Oriented Programming using JAVA (MC01094041)

BY

PATIL HIRAL VASANTBHAI

Supervised by :-

Prof. Bhavesh B. Prajapati

MASTER OF COMPUTER APPLICATION

Government MCA College


Khokhra, Ahmedabad
380008 Affiliated to
GUJARAT TECHNOLOGICAL UNIVERSITY
Academic Year 2025-26
Academic Year:2024-2025

GOVERNMENT MCA COLLEGE, Maninager(East)


K.K.shastri Educational Campus
Khokhra Road, Ahmedabad -380008, +Gujarat

CERTIFICATE

This is to certify that Patil Hiral Vasantbhai


Student of MCA Semester-I, Government MCA College Has Successfully
completed his Practical submission on subject “Object Oriented
Programming using JAVA (MC01094041)” of Semester-1 Master of
computer Application of Gujarat Technological University , Ahmedabad
during academic year 2025-2026

DATE OF SUBMISSION:

-------------------------------------- ---------------------------
Prof. Bhavesh B Prajapati Head Dr.Chetan B Bhatt
&Assistant Professor IT Principal Government
Government MCA College MCA College,
Maninagar Maninagar
Object Oriented Programming using JAVA (MC01094041)

VISION OF THE INSTITUTE

 Provide value-based quality education for computer science applications which enable
students to solve real-life problems of society.

MISSION OF THE INSTITUTE

 To equip our students with good knowledge, skills and attitude to solve real – life problems in
the domain of computer applications.
 To establish industry-academia interaction to facilitate the students to work proficiently in the
industrial environment.
 To imbibe high moral values and professional ethics.
 To provide conducive environment so as to achieve excellence in teaching-learning, and
research and development activities.

PROGRAM EDUCATIONAL OBJECTIVES

 Identify and analyze real life problems and design computing systems appropriate to its
solutions that are technically sound, economically feasible and socially acceptable
 Exhibit professionalism, ethical attitude, good communication skills, team work in their
profession
 Adapt to current trends by engaging in life-long learning

Patil Hiral Vasantbhai 3|Page


Object Oriented Programming using JAVA (MC01094041)

PROGRAM OUTCOMES (POs)

 PO1 (Foundation Knowledge): Apply knowledge of mathematics, programming logic and


coding fundamentals for solution architecture and problem solving.
 PO2 (Problem Analysis): Identify, review, formulate and analyze problems for primarily focusing
on customer requirements using critical thinking frameworks.
 PO3 (Development of Solutions): Design, develop and investigate problems with as an innovative
approach for solutions incorporating ESG/SDG goals.
 PO4 (Modern Tool Usage): Select, adapt and apply modern computational tools such as
development of algorithms with an understanding of the limitations including human biases.
 PO5 (Individual and Teamwork): Function and communicate effectively as an individual or a
team leader in diverse and multidisciplinary groups. Use methodologies such as agile.
 PO6 (Project Management and Finance): Use the principles of project management such
as scheduling, work breakdown structure and be conversant with the principles of Finance for
profitable project management.
 PO7 (Ethics): Commit to professional ethics in managing software projects with financial aspects.
Learn to use new technologies for cyber security and insulate customers from malware
 PO8 (Life-long learning): Change management skills and the ability to learn, keep up with
contemporary technologies and ways of working.

Patil Hiral Vasantbhai 4|Page


Object Oriented Programming using JAVA (MC01094041)

PROGRAM SPECIFIC OUTCOMES (PSOs)

After completing the program students will be able to:

 Meet the needs of users within an organizational and societal context through the selection,
creation, application, integration, and administration of computing technologies.
 Apply concepts, probability, statistics, mathematics, through calculus (differential and
integral), numerical methods and sciences including applications appropriate in the field of
computing problems.
 Use algorithms, data structures, database management, software design, concepts of
programming languages and computer organization and architecture in the field of
computer applications.

Patil Hiral Vasantbhai 5|Page


Object Oriented Programming using JAVA (MC01094041)

COURSE OUTCOMES (COs)


After completion of the course, student will able to:

 Describe Java features, OOP concepts and Write console java program syntax and semantics
using datatypes, variables, control and looping statements.
 Explain and Implement class, object, encapsulation and polymorphism in JAVA.
 Apply the concept of inheritance, package and exception handling for reusable, structured and
error free programs.
 Use wrapper class and Collection interface to convert and manage list of data.
 Describe and Implement multithreaded programs, Generic class and IO programs.

Patil Hiral Vasantbhai 6|Page


Object Oriented Programming using JAVA (MC01094041)

Sr.No AIM Date Signature

1. Install the JDK (Download the JDK and install it.)


Set path of the jdk/bin directory.
Create the java program
Compile and run the java program

Write a simple “Hello World” java program,


compilation, debugging, executing using java compiler
and interpreter.
2. Write a program to pass Starting and Ending limit and
print all prime numbers and Fibonacci numbers between
this ranges.

3. Write a java program to check whether number is


palindrome or not.
Input: 528 Output: It is not palindrome number
Input: 545 Output: It is not palindrome number
4. Write a java program to print value of x^n. Input: x=5
Input: n=3 Output: 125

5. Write a java program to check Armstrong number. Input:


153 Output: Armstrong number
Input: 22 Output: not Armstrong number
6. Write a program in Java to find minimum of three numbers
using conditional operator.
7. Write a java program which should display maximum
number of given 4 numbers.
8. Write a program in Java to multiply two matrix.
Declare a class Matrix where 2D array is declared as
instance variable and array should be initialized, within
class.
9. Write a java program to create a class “Matrix” that would
contain integer values having varied Numbers of columns
for each row. Print row-wise sum of the integer values for
each row.
10. Write a Java application which takes several command line
arguments, which are supposed to be names of students
and prints output as given below:
(Suppose we enter 3 names then output should be as
follows).. Number of arguments = 3
1. First Student Name is = Arun
2. Second Student Name is = Hiren
3. Third Student Name is = Hitesh
11. Write a Java application to count and display frequency of
letters and digits from the String given by user as
command-line argument.
12 Create a class “Student” that would contain enrollment No,
name, and gender and marks as instance variables and
count as static variable which stores the count of the
objects; constructors and display(). Implement constructors
Patil Hiral Vasantbhai 7|Page
Object Oriented Programming using JAVA (MC01094041)
to initialize instance variables. Also demonstrate
constructor chaining. Create objects of class “Student” and
displays all values of objects.
13 Write a program in Java to demonstrate use of this
keyword. Check whether this can access the Static
variables of the class or not. [Refer class student in Q12 to
perform the task]

14 Create a class “Rectangle” that would contain length and


width as an instance variable and count as a static variable.
Define constructors [constructor overloading (default,
parameterized and copy)] to initialize variables of objects.
Define methods to find area and to display variables’ value
of objects which are created.
[Note: define initializer block, static initializer block and
the static variable and method. Also demonstrate the
sequence of execution of initializer block and static
initialize block]
15 Write a java program static block which will be executed
before main ( ) method in a
Class.
16 Write programs in Java to use Wrapper class of each
primitive data types.

17 Write a class “circle” with radius as data member and


count the number of instances created using default
constructor only. [Constructor Chaining]

18 Create a class “Vehicle” with instance variable


vehicle_type. Inherit the class in a class called “Car” with
instance model_type, company name etc. display the
information of the vehicle by defining the display() in both
super and sub class [Method Overriding]

19 Create a class “Account” containing accountNo, and


balance as an instance variable. Derive the Account class
into two classes named “Savings” and “Current”. The
“Savings” class should contain instance variable named
interestRate, and the “Current” class should contain
instance variable called overdraftLimit. Define appropriate
methods for all the classes to enable functionalities to
check balance, deposit, and withdraw amount in Savings
and Current account. [Ensure that the Account class cannot
be instantiated.]

20 Write a program in Java in which a subclass constructor


invokes the constructor of the super class and instantiate
the values. [ refer class Account and sub classes
savingAccount and CurrentAccount in Q 19 for this task]

Patil Hiral Vasantbhai 8|Page


Object Oriented Programming using JAVA (MC01094041)
21 Write a program in Java to demonstrate the use of 'final'
keyword in the field declaration. How it is accessed using
the objects.
22 Write a java program to illustrate how to access a hidden
variable. Class A declares a static variable x. The class B
extends A and declares an instance variable x. display ( )
method in B displays both of these variables.

23 Describe abstract class called Shape which has three


subclasses say Triangle, Rectangle, and Circle. Define one
method area () in the abstract class and override this area ()
in these three subclasses to calculate for specific object i.e.
area () of Triangle subclass should calculate area of
triangle etc. Same for Rectangle and Circle

24 Write a java program to implement an interface called


Exam with a method Pass (int mark) that returns a boolean.
Write another interface called Classify with a method
Division (int average) which returns a String. Write a class
called Result which implements both Exam and Classify.
The Pass method should return true if the mark is greater
than or equal to 50 else false. The Division method must
return “First” when the parameter average is 60 or more,
“Second” when average is 50 or more but below 60, “No
division” when average is less than 50.

25 Assume that there are two packages, student and exam. A


student package contains Student class and the exam
package contains Result class. Write a program that
generates mark sheet for students.
26 Define a class A in package apack. In class A, three
variables are defined of access modifiers protected, private
and public. Define class B in package bpack which extends
A and write display method which accesses variables of
class A.
Define class C in package cpack which has one method
display() in that create one object of class A and display its
variables. Define class ProtectedDemo in package dpack in
which write main () method. Create objects of class B and
C and class display method for both these objects.
27 Write a java program to implement Generic class
Number_1 for both data type int and float in java.
28 Write a java program to accept string to check whether it is
in Upper or Lower case. After checking, case will be
reversed.
29 Write a java program to use important methods of String
class.
30 Write a program in Java to demonstrate use of final class,
final variable and final method

Patil Hiral Vasantbhai 9|Page


Object Oriented Programming using JAVA (MC01094041)
31 Write a program in Java to develop user defined exception
for 'Divide by Zero' error
32 Write a program in Java to demonstrate throw, throws,
finally, multiple try block and multiple catch exception.
33 Write a small application in Java to develop Banking
Application in which user deposits the amount Rs 1000.00
and then start withdrawing of Rs 400.00, Rs 300.00 and it
throws exception "Not Sufficient Fund" when user
withdraws Rs. 500 thereafter.

34 Write a program to write at least 10 objects of the Circle


class in a File and to perform basic operations: adding,
retrieving, updating, removing elements.

35 Write a program for Java Generics class for Sorting


operations:
1. Sorting a list according to natural ordering of elements
2. Reversing sort order
3. Sorting a list whose elements of a custom type
4. Sorting a list using a Comparator. [desirable]
36 Write a program in Java to create, write, modify, read
operations on a Text file.

37 Write a java program to illustrate use of standard input


stream to read the user input.

38 Write a java program to checks the existence of a specified


file.

39 Write a java program to create a file to the specified


location.

40 Write a java program to demonstrate the way contents are


read from a file.

41 Write a java program to count the availability of text lines


in the particular file. A file is read before counting lines of
a particular file.

42 Write a generic method to count the number of elements in


a collection that have a specific
property (for example, odd integers, prime numbers,
palindromes).
43 Write a generic method to exchange the positions of two
different elements in an array.

Thread Programming

1 Write a program to implement the concept of threading by


extending “Thread” Class.

Patil Hiral Vasantbhai 10 | P a g e


Object Oriented Programming using JAVA (MC01094041)
2 Write a program to implement the concept of threading by
implementing “Runnable”
Interface.
3 Write a program that executes two threads. One thread
displays “Thread1” every 2,000 milliseconds, and the other
displays “Thread2” every 4,000 milliseconds.
4 Write a program that executes two threads. One thread will
print the even numbers and another thread will print odd
numbers from 1 to 50.
5 Write java program that create and runs following threads:
a) print "A" 20 times
b) print "B" 30 times
c) print "C" 15 times
6 Write a program in Java to demonstrate use of
synchronization of threads when multiple threads are
trying to update common variable for “Account” class.

The collection Framework

1 Develop a program to create Linked List for “Student”


class objects references. “Student” class has std_id,
std_name, Array of marks, total_ marks. Calculate
total_marks for all students of Linked List. Display Linked
List and also display a particular student based on student
name as a command line argument.
2 Develop a program to create Array List for “Employee”
class objects references. Employee class has emp_code,
emp_name, basic_sal, gross_ sal. Calculate gross_sal for
all employees of Array List. Display Array List and also
insert an employee object reference in a particular position
(input) in Array List.
Gross_sal=basic_sal+20% of basic_sal (MA)+30% of
basic_sal(HRA)
3 Develop a program to create Hash Map for “Customer”
class objects references. Customer class has Bill_no,
cust_mobile_no, Array of item_name, Array of
item_unit_price, Array of item_count, total_price.
Calculate total_price for all customers of Hash Map.
Display Hash Map and also search particular customer’s
bill based on customer mobile no. Key is mobile no.
4 Sort “Student” Linked List (mentioned in Q:1) based on
std_name using “Comparator” interface.

Patil Hiral Vasantbhai 11 | P a g e


Object Oriented Programming using JAVA (MC01094041)

Program 1

Install the JDK (Download the JDK and install it.)


• Set path of the jdk/bin directory.
• Create the java program
• Compile and run the java program Write a simple “Hello World” java
program, compilation, debugging, executing using java compiler and interpreter.

Patil Hiral Vasantbhai 12 | P a g e


Object Oriented Programming using JAVA (MC01094041)

Code :

public class pro1 {


public static void main(String[] args)
{
System.out.println("\n");
System.out.println("Hello, World!");
}
}

Output:

Patil Hiral Vasantbhai 13 | P a g e


Object Oriented Programming using JAVA (MC01094041)
Program 2

Write a program to pass Starting and Ending limit and print all prime numbers and
Fibonacci numbers between this ranges.

Code:
import java.util.*;

public class pro2 {


public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter starting limit: ");
int start = sc.nextInt();

System.out.print("Enter ending limit: ");


int end = sc.nextInt();

System.out.print("\nPrime numbers between " + start + " and " + end + ": ");
for (int i = start; i <= end; i++) {
if (i > 1) {
boolean isPrime = true;
for (int j = 2; j * j <= i; j++) {
if (i % j == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
System.out.print(i + " ");
}
}
}
System.out.print("\nFibonacci numbers between " + start + " and " + end + ": ");
int a = 0, b = 1;
while (a <= end) {
if (a >= start) {
System.out.print(a + " "); }
int next = a + b;
a = b;
b = next;
}
sc.close();
}
}
Output:

Patil Hiral Vasantbhai 14 | P a g e


Object Oriented Programming using JAVA (MC01094041)

Program 3

Write a java program to check whethernumber is palindrome or not.


Input: 528 Output: It is not palindromenumber
Input: 545 Output: It is not palindrome number

Code:

import java.util.Scanner;

public class pro3 {


public static void main(String[] args) {
Scanner sc = new Scanner(System.in);

System.out.print("Enter a number: ");


int number = sc.nextInt();

int original = number;


int reversed = 0;

while (number > 0) {


int digit = number % 10;
reversed = reversed * 10 + digit;
number = number / 10;
}

if (original == reversed) {
System.out.println(original + " is a palindrome number ");
} else {
System.out.println(original + " is not a palindrome number ");
}

sc.close();
}
}

Output:

Patil Hiral Vasantbhai 15 | P a g e


Object Oriented Programming using JAVA (MC01094041)

Program 4
Write a java program to print value ofx^n. Input: x=5 Input: n=3 Output: 125

Code:
import java.util.Scanner;

public class pro4 {


public static void main(String[] args) {
Scanner sc = new Scanner(System.in);

System.out.print("Enter the base number (x): ");


int x = sc.nextInt();

System.out.print("Enter the exponent (n): ");


int n = sc.nextInt();

int result = 1;

for (int i = 1; i <= n; i++) {


result *= x;
}

System.out.println(x + " raised to the power " + n + " = " + result);

sc.close();
}
}

Output:

Patil Hiral Vasantbhai 16 | P a g e


Object Oriented Programming using JAVA (MC01094041)

Program 5

Write a java program to check Armstrong number. Input: 153 Output:Armstrong


number
Input: 22 Output: not Armstrong number

Code:
import java.util.Scanner;

public class pro5 {


public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number: ");
int num = sc.nextInt(), sum = 0, temp = num;

int digits = String.valueOf(num).length();

while (temp > 0) {


int digit = temp % 10;
int power = 1;
for (int i = 0; i < digits; i++) {
power *= digit; // compute digit^digits
}
sum += power;
temp /= 10;
}

System.out.println(num + (sum == num ? " is an Armstrong number" : " is not an Armstrong


number"));
sc.close();
}
}

Output:

Patil Hiral Vasantbhai 17 | P a g e

You might also like