0% found this document useful (0 votes)
162 views

CE219.01 Practical List

This document outlines the practical assignments for an Object Oriented Programming using Java course. It includes 6 parts covering various Java concepts: 1. Data types, variables, arrays, operators, control statements and strings 2. Object oriented programming concepts like classes, methods and inheritance 3. Packages and interfaces 4. Exception handling 5. File handling and streams 6. Multithreading It provides 7 assignments for each part, totaling 42 assignments that students must complete to learn and demonstrate their understanding of key Java topics. The assignments increase in complexity and cover fundamental skills up to more advanced concepts like multithreading and file I/O.

Uploaded by

anon_860045317
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)
162 views

CE219.01 Practical List

This document outlines the practical assignments for an Object Oriented Programming using Java course. It includes 6 parts covering various Java concepts: 1. Data types, variables, arrays, operators, control statements and strings 2. Object oriented programming concepts like classes, methods and inheritance 3. Packages and interfaces 4. Exception handling 5. File handling and streams 6. Multithreading It provides 7 assignments for each part, totaling 42 assignments that students must complete to learn and demonstrate their understanding of key Java topics. The assignments increase in complexity and cover fundamental skills up to more advanced concepts like multithreading and file I/O.

Uploaded by

anon_860045317
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/ 5

CHAROTAR UNIVERSITY OF SCIENCE & TECHNOLOGY

FACULTY OF TECHNOLOGY AND ENGINEERING


U. & P. U. Patel Department of Computer Engineering

Subject Name: Object Oriented Programming using Java Semester: IV


Subject Code: CE219.01 Academic year: Dec-May 2016/2017

Practical List

PART-I
Data Types, Variables, Arrays, Operators, Control Statements, String
1. Introduction to Object Oriented Concepts, comparison of Java with other object oriented
programming languages. Introduction to JDK, JRE, JVM, javadoc, command line
argument
2. Write a program to calculate total surface area of the exterior of the house.
Ask user for
a) House length, width and height
b) Number of windows and size of window
c) Number of doors and size of door
Calculate total surface area to be painted.
3. Randomly generate two dice values 100 times and count how many times we roll in
doubles.
Ex. Two dice values roll into (1, 1), then increment counter by 1.
Hint: Import Random library.

4. Display numbers in a pyramid pattern.


1
121
12421
1248421
1 2 4 8 16 8 4 2 1
1 2 4 8 16 32 16 8 4 2 1
1 2 4 8 16 32 64 32 16 8 4 2 1
1 2 4 8 16 32 64 128 64 32 16 8 4 2 1
5. The problem is to write a program that will grade multiple-choice tests. Assume there
are eight students and ten questions, and the answers are stored in a two-dimensional
array. Each row records a student’s answers to the questions, as shown in the following
array.
Students’ Answers to the Questions:
0 1 2 3 4 5 6 7 8 9
Student 0 A B A C C D E E A D
Student 1 D B A B C A E E A D
Student 2 E D D A C B E E A D
Student 3 C B A E D C E E A D
Student 4 A B D C C D E E A D
Student 5 B B E C C D E E A D
Student 6 B B A C C D E E A D
Student 7 E B E C C D E E A D
The key is stored in a one-dimensional array:
Key to the Questions:
0123456789
Key D B D C C D A E A D
Your program grades the test and displays the result. It compares each student’s answers
with the key, counts the number of correct answers, and displays it.
6. The problem is to check whether a given Sudoku solution is correct.

7. Implement Caesar Cipher.


PART-II
Object Oriented Programming : Classes, Methods, Inheritance
1. Design a class named Circle containing following attributes and behavior.
 One double data field named radius. The default value is 1.
 A no-argument constructor that creates a default circle.
 A Single argument constructor that creates a Circle with the specified radius.
 A method named getArea() that returns area of the Circle.
 A method named getPerimeter() that returns perimeter of it.
2. Design a class named Account that contains:
 A private int data field named id for the account (default 0).
 A private double data field named balance for the account (default 500₹).
 A private double data field named annualInterestRate that stores the current interest rate
(default 7%). Assume all accounts have the same interest rate.
 A private Date data field named dateCreated that stores the date when the account was
created.
 A no-arg constructor that creates a default account.
 A constructor that creates an account with the specified id and initial balance.
 The accessor and mutator methods for id, balance, and annualInterestRate.
 The accessor method for dateCreated.
 A method named getMonthlyInterestRate() that returns the monthly interest rate.
 A method named getMonthlyInterest() that returns the monthly interest.
 A method named withdraw that withdraws a specified amount from the account.
 A method named deposit that deposits a specified amount to the account.
3. Use the Account class created as above to simulate an ATM machine.
Create 10 accounts with id AC001…..AC010 with initial balance 300₹. The system
prompts the users to enter an id. If the id is entered incorrectly, ask the user to enter a
correct id. Once an id is accepted, display menu with multiple choices.
1. Balance inquiry
2. Withdraw money [Maintain minimum balance 300₹]
3. Deposit money
4. Money Transfer
5. Create Account
6. Deactivate Account
7. Exit
Hint: Use ArrayList, which is can shrink and expand with compared to Array.
4. (Subclasses of Account) In Programming Exercise 2, the Account class was defined to
model a bank account. An account has the properties account number, balance, annual
interest rate, and date created, and methods to deposit and withdraw funds. Create two
subclasses for checking and saving accounts. A checking account has an overdraft limit,
but a savings account cannot be overdrawn. Draw the UML diagram for the classes and
then implement them. Write a test program that creates objects of Account,
SavingsAccount, and CheckingAccount and invokes their toString() methods.
5. Develop a Program that illustrate method overloading concept.
PART-III
Package & Interface
1. WAP that illustrate the use of interface reference. Interface Luminious Object has two
method lightOn() and lightOff(). There is one class Solid extended by 2 classes Cube and
Cone. There is one class LuminiousCone extends Cone and implements Luminoius
Interface. LumminuiousCube extends Cube and implements Luminious Interface. Create a
object of LuminiousCone and LuminousCube and use the concept of interface reference to
invoke the methods of interface.

2. WAP that illustrate the interface inheritance.


Interface P is extended by P1 and P2 interfaces.
Interface P12 extends both P1 and P2. Each interface declares one method and one
constant. Create one class that implemetns P12. By using the object of the class invokes
each of its method and displays constant.

3. Create an abstract class Robot that has the concretre subclasses , RobotA, RobotB,
RobotC. Class RobotA1 extends RobotA, RobotB1 extends RobotB and RobotC1 extends
RobotC. There is interface Motion that declares 3 methods forward(), reverse() and stop(),
implemented by RobotB and RobotC. Sound interface declare method beep() implemented
by RobotA1, RobotB1 and RobotC1. Create an instance method of each class and invoke
beep() and stop() method by all objects.

4. Develop a Program that illustrate method overriding concept.


5. Write a java program which shows importing of classes from other user define packages.

6. Write a program that demonstrates use of packages & import statements.

7. Write a program that illustrates the significance of interface default method.

PART-IV
Exception Handling
1. WAP to show the try - catch block to catch the different types of exception.

2. WAP to generate user defined exception using “throw” and “throws” keyword.

Write a program that raises two exceptions. Specify two ‘catch’ clauses for the two
exceptions. Each ‘catch’ block handles a different type of exception. For example the
3.
exception could be ‘ArithmeticException’ and ‘ArrayIndexOutOfBoundsException’.
Display a message in the ‘finally’ block.
PART-V
File Handling & Streams
1. WAP to show how to create a file with different mode and methods of File class to find
path, directory etc.
2. Write a program to show a tree view of files and directories under a specified
drive/volume.
3. Write a program to transfer data from one file to another file so that if the destination
file does not exist, it is created.
4. WAP to show use of character and byte stream.
5. WAP to read console input and write them into a file.
(BufferedReader /BufferedWriter).
6. WAP to demonstrate methods of wrapper class.

PART-VI
Multithreading
1. Write a program to create thread which display “Hello World” message.
A. by extending Thread class
B. by using Runnable interface.
2. Write a program which takes N and number of threads as an argument. Program should
distribute the task of summation of N numbers amongst number of threads and final
result to be displayed on the console.
3. Write a program to increment the value of one variable by one and display it after one
second using thread using sleep() method.

4. Write a program to create three threads ‘FIRST’, ‘SECOND’, ‘THIRD’. Set the
priority of the ‘FIRST’ thread to 3, the ‘SECOND’ thread to 5(default) and the
‘THIRD’ thread to 7.
5. Write a program to solve producer-consumer problem using thread synchronization.

PART-VII
Collection Framework and Generic
1. Create a generic method for sorting an array of Comparable objects.
2. Write a program that counts the occurrences of words in a text and displays the words and
their occurrences in alphabetical order of the words. Using Map and Set Classes.

3. Write a code which counts the number of the keywords in a Java source file. Store all the
keywords in a HashSet and use the contains method to test if a word is in the keyword set.

Self Study: Lambda Expression


Beyond Syllabus: New features coming in Java9

You might also like