Object Oriented Programming in Java
Object Oriented Programming in Java
With effective
Syllabus for Master of Computer Applications, 1st Semester from academic
Subject Name: Object Oriented Programming in Java year 2020-21
Subject Code: 619402
1. Learning Objectives:
To develop proficiency in creating console based applications using the
Java Programming Language.
To interpret the concepts of object oriented Programming Language and
easily use these concepts in Java program.
To develop application using java.util package (Java data structure).
To implement multi-threaded applications using the Java Programming Language.
To implement application including different file operations.
3. Contents:
Weightage
Unit Chapter Details
Percentage
Unit I Introduction to Java 15%
Page no. 1 of 9
GUJARAT TECHNOLOGICAL UNIVERSITY
With effective
Syllabus for Master of Computer Applications, 1st Semester from academic
Subject Name: Object Oriented Programming in Java year 2020-21
Subject Code: 619402
Statement,
Nested switch Statements, The for Loop, Some Variations on the
for Loop, Missing Pieces (The Infinite Loop), Loops with No
Body, Declaring Loop Control Variables Inside the for Loop, The
Enhanced for Loop, The while Loop, The do-while Loop, Use
break to Exit a Loop,
Use break as a Form of goto, Use continue, Nested Loops,
Page no. 2 of 9
GUJARAT TECHNOLOGICAL UNIVERSITY
With effective
Syllabus for Master of Computer Applications, 1st Semester from academic
Subject Name: Object Oriented Programming in Java year 2020-21
Subject Code: 619402
Page no. 3 of 9
GUJARAT TECHNOLOGICAL UNIVERSITY
With effective
Syllabus for Master of Computer Applications, 1st Semester from academic
Subject Name: Object Oriented Programming in Java year 2020-21
Subject Code: 619402
Using I/O: Java’s I/O Is Built upon Streams, Byte Streams and
Character Streams, The Byte Stream Classes, The Character Stream
Classes, The Predefined Streams, Using the Byte Streams (Reading
Console Input, Writing Console Output), Reading and Writing Files
Using Byte Streams (Inputting from a File, Writing to a File),
Automatically Closing a File, Reading and Writing Binary Data,
Notes: Desirable:
1. java.util package and scanner class, formatter class, chapter 13 of Pravin Jain, “The
class of Java” Pearson Education, (2010).
2. Working with Maps, map classes, The comparator interface
3. Thread communication using notify() , wait(0 and notifyall(), Suspending, resuming
and stopping threads
4. Text Book:
5. Reference Books:
6. Webliography:
Page no. 4 of 9
GUJARAT TECHNOLOGICAL UNIVERSITY
With effective
Syllabus for Master of Computer Applications, 1st Semester from academic
Subject Name: Object Oriented Programming in Java year 2020-21
Subject Code: 619402
I 1 Chapter 1,2,3
II 1 Chapter 4,5,6
III 1 Chapter 7,8,9
IV 1 Chapter 12 ((pages 430 to 436)
String (pages 158-164), StringBuffer(page 163,
javadoc/api), Comparable interface (page: 464,466,
javadoc/api)
IV 2 Chapter 18 (18.1 to 18.9 pages 534 to 566)
V 1 Chapter 11,13 (pages 445 to 453) ,10 (pages 331 to 351)
9. Laboratory Exercises
A. List of Practical Related to JAVA:
Page no. 5 of 9
GUJARAT TECHNOLOGICAL UNIVERSITY
With effective
Syllabus for Master of Computer Applications, 1st Semester from academic
Subject Name: Object Oriented Programming in Java year 2020-21
Subject Code: 619402
2 Write a program to pass Starting and Ending limit and print all prime numbers and
Fibonacci
numbers between this range.
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 to initialize instance
variables.
Page no. 6 of 9
GUJARAT TECHNOLOGICAL UNIVERSITY
With effective
Syllabus for Master of Computer Applications, 1st Semester from academic
Subject Name: Object Oriented Programming in Java year 2020-21
Subject Code: 619402
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]
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 illustrates 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
Page no. 7 of 9
GUJARAT TECHNOLOGICAL UNIVERSITY
With effective
Syllabus for Master of Computer Applications, 1st Semester from academic
Subject Name: Object Oriented Programming in Java year 2020-21
Subject Code: 619402
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
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.
42 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.
Page no. 8 of 9
GUJARAT TECHNOLOGICAL UNIVERSITY
With effective
Syllabus for Master of Computer Applications, 1st Semester from academic
Subject Name: Object Oriented Programming in Java year 2020-21
Subject Code: 619402
43 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).
44 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.
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:
i) print "A" 20 times
ii) print "B" 30 times
iii) 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.
Page no. 9 of 9