0% found this document useful (0 votes)
86 views9 pages

Eojwo

This document outlines the course outcomes and practical list for a Java Programming course. The course aims to teach students to: 1) Implement object-oriented programming concepts in Java 2) Demonstrate problem-solving skills by analyzing problems and implementing solutions in Java 3) Use concurrency theory and new Java I/O APIs and exception handling 4) Apply collection frameworks and generics to solve data structure problems 5) Understand new Java features The practical list covers topics like data types, strings, object-oriented programming, inheritance, interfaces and packages. It includes exercises to write Java programs implementing these concepts.

Uploaded by

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

Eojwo

This document outlines the course outcomes and practical list for a Java Programming course. The course aims to teach students to: 1) Implement object-oriented programming concepts in Java 2) Demonstrate problem-solving skills by analyzing problems and implementing solutions in Java 3) Use concurrency theory and new Java I/O APIs and exception handling 4) Apply collection frameworks and generics to solve data structure problems 5) Understand new Java features The practical list covers topics like data types, strings, object-oriented programming, inheritance, interfaces and packages. It includes exercises to write Java programs implementing these concepts.

Uploaded by

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

Charotar University of Science and

Technology
Devang Patel Institute of Advance Technology and Research
Department of Computer Science & Engineering

Subject: Java Programming Semester:3


Subject Code: CE251 AcademicYear:2022-23

Course Outcomes (COs):


After completion of the course students will be able to:

1. Understand and implement Object Oriented programming concept using basic syntaxes
of control Structures, strings and function for developing skills of logic building activity
and garbage collection for saving resources.
2. Demonstrate basic problem-solving skills: analyzing problems, modeling a problem as a
system of objects, creating algorithms, and implementing models and algorithms in an
object-oriented computer language (classes, objects, methods with parameters, abstract
classes, interfaces, inheritance and polymorphism).
3. Use and develop Concurrency theory: progress guarantees, deadlock, live lock, starvation,
linearizability.
4. Build and test program using new IO api and exception handling
5. Analyze and apply collection framework and generics to solve different data structure
algorithms.
6. Understand and apply java new features

Practical List
S AI H CO
r. M rs s
N
o.
PART-I Data Types, Variables, String, Control Statements, Operators, Arrays

1 Introduction to Object Oriented Concepts, comparison of Java with 1 1


other object-oriented programming languages. Introduction to JDK,
JRE, JVM, Javadoc, command line argument. Introduction to Eclipse
or NetBeans IDE,or BlueJ and Console Programming.
2 Write a program that declares one integer variable called var1. Give 1 1
value 10 to this variable and then, using one println() statement,
display the value on the screen like this: “10 is the value of var1.”

3 Write a console program to declare and initialize a double variable 1 1


with some value such as 1234.5678. Then retrieve the integral part of
the value and store it in a variable of type long, and the first four
digits of the fractional part and store them in an integer of type short.
Display the value of the double variable by outputting the two values
stored as integers.
4 Write an application that creates a two-dimension array with int 1 1, 2
values. The first, second and third elements should be arrays with
one, two and three numbers respectively. Display the length of each
dimension.
5 An electric appliance shop assigns code 1 to motor,2 to fan,3 to tube 1 1, 2
and 4 for wires. All other items have code 5 or more. While selling
the goods, a sales tax of 8% to motor,12% to fan,5% to tube
light,7.5% to wires and 3% for all other items is charged. A list
containing the product code and price in two different arrays. Write a
java program using switch statement to prepare the bill.
6 Write a program to show output like: 1 1,2
*
**
***
****
*****
PART-II String
1 Given a string and a non-negative int n, we'll say that the front of the 1 1, 2
string is the first 3 chars, or whatever is there if the string is less than
length 3. Return n copies of the front;
front_times('Chocolate', 2) → 'ChoCho'
front_times('Chocolate', 3) → 'ChoChoCho'
front_times('Abc', 3) → 'AbcAbcAbc'
2 Given an array of ints, return the number of 9's in the array. 1 1, 2
array_count9([1, 2, 9]) → 1
array_count9([1, 9, 9]) → 2
array_count9([1, 9, 9, 3, 9]) → 3
3 Given an array of ints, return True if one of the first 4 elements in the 1 1, 2
array is a 9. The array length may be less than 4.
array_front9([1, 2, 9, 3, 4]) → True
array_front9([1, 2, 3, 4, 9]) → False
array_front9([1, 2, 3, 4, 5]) → False
4 Given a string, return a string where for every char in the original, 1 1, 2
there are two chars.
double_char('The') → 'TThhee'
double_char('AAbb') → 'AAAAbbbb'
double_char('Hi-There') → 'HHii--TThheerree'
5 Write a program that will reverse the sequence of letters in each word 1 1, 2
of your chosen paragraph. For instance, “To be or not to be” would
become “oT e bro ton ot eb”.
6 Perform following functionalities of the string: 1 1, 2
● Find Length of the String
● Lowercase of the String
● Uppercase of the String
● Reverse String
● Sort the string
7 Perform following Functionalities of the string: 1 1, 2
“CHARUSAT University”
● Find length
● Replace ‘H’ by ‘N’
● Convert all character in Uppercase
● Extract and print “CHARUSAT” from given string
PART-III Object Oriented Programming: Classes, Methods, Constructors

1 Write a java program for converting Pound into Rupees. (Accept 1 2


Pounds from command line argument and using scanner class also and
take 1 Pound = 100 Rupees.)
2 Write a program that defines TriangleArea class with three 1 1, 2
constructors. The first form accepts no arguments. The second accept
one double value for radius. The third form accepts any two
arguments.
3 Create a class called Employee that includes three pieces of 1 1, 2
information as instance variables—a first name (type String), a last
name (type String) and a monthly salary (double). Your class should
have a constructor that initializes the three instance variables. Provide
a set and a get method for each instance variable. If the monthly salary
is not positive, set it to 0.0. Write a test application named
EmployeeTest that demonstrates class Employee’s capabilities. Create
two Employee objects and display each object’s yearly salary. Then
give each Employee a 10% raise and display each Employee’s yearly
salary again.
4 Create a class called Date that includes three pieces of information as 1 1, 2
instance variables—a month (type int), a day (type int) and a year
(type int). Your class should have a constructor that initializes the
three instance variables and assumes that the values provided are
correct. Provide a set and a get method for each instance variable.
Provide a method displayDate that displays the month, day and year
separated by forward slashes (/). Write a test application named
DateTest that demonstrates class Date’s capabilities.
5 Write a program to print the area of a rectangle by creating a class 1 1, 2
named 'Area' taking the values of its length and breadth as parameters
of its constructor and having a method named 'returnArea' which
returns the area of the rectangle. Length and breadth of rectangle are
entered through keyboard.
6 Print the sum, difference and product of two complex numbers by 1 1, 2
creating a class named ‘Complex’ with separate methods for each
operation whose real and imaginary parts are entered by user.
7 Complete the code and write main () method to execute program. 1 2

public class MethodOverloading


{
private void methodOverloaded()
{
//no argument, private method
}
private int methodOverloaded(int i)
{
//code
}
protected int methodOverloaded(double d)
{
//code
}
public void methodOverloaded(int i, double d)
{
//code
}
}

PART-IV Inheritance, Interface, Package


1 Create a class with a method that prints "This is parent class" and its 1 1, 2,
subclass with another method that prints "This is child class". Now, 3
create an object for each of the class and call 1 - method of parent class
by object of parent class 2 - method of child class by object of child
class 3 - method of parent class by object of child class
2 Create a class named 'Member' having the following members: 1 1, 2,
Data members 3
1 - Name
2 - Age
3 - Phone number
4 - Address
5 – Salary
It also has a method named 'printSalary' which prints the salary of the
members.
Two classes 'Employee' and 'Manager' inherits the 'Member' class. The
'Employee' and 'Manager' classes have data members 'specialization'
and 'department' respectively. Now, assign name, age, phone number,
address and salary to an employee and a manager by making an object
of both of these classes and print the same.
3 Create a class named 'Rectangle' with two data members 'length' and 1 2, 3
'breadth' and two methods to print the area and perimeter of the
rectangle respectively. Its constructor having parameters for length and
breadth is used to initialize length and breadth of the rectangle. Let
class 'Square' inherit the 'Rectangle' class with its constructor having a
parameter for its side (suppose s) calling the constructor of its parent
class as 'super(s,s)'. Print the area and perimeter of a rectangle and a
square. Also use array of objects.
4 Create a class named 'Shape' with a method to print "This is This is 1 2, 3
shape". Then create two other classes named 'Rectangle', 'Circle'
inheriting the Shape class, both having a method to print "This is
rectangular shape" and "This is circular shape" respectively. Create a
subclass 'Square' of 'Rectangle' having a method to print "Square is a
rectangle". Now call the method of 'Shape' and 'Rectangle' class by the
object of 'Square' class.
5 Create a class 'Degree' having a method 'getDegree' that prints "I got a 1 2, 3
degree". It has two subclasses namely 'Undergraduate' and
'Postgraduate' each having a method with the same name that prints "I
am an Undergraduate" and "I am a Postgraduate" respectively. Call the
method by creating an object of each of the three classes.
6 Write a java that implements an interface AdvancedArithmetic which 1 2, 3
contains amethod signature int divisor_sum(int n). You need to write a
class calledMyCalculator which implements the interface. divisorSum
function just takes an integer as input and return the sum of all its
divisors.
For example, divisors of 6 are 1, 2, 3 and 6, so divisor_sum should
return 12. The value of n will be at most 1000.
7 Assume you want to capture shapes, which can be either circles (with a 1 2, 3
radius and a color) or rectangles (with a length, width, and color). You
also want to be able to create signs (to post in the campus center, for
example), each of which has a shape (for the background of the sign)
and the text (a String) to put on the sign. Create classes and interfaces
for circles, rectangles, shapes, and signs. Write a program that
illustrates the significance of interface default method.
8 Write a java program which shows importing of classes from other 1 6
user define packages.
PART-V Exception Handling
9 Write a java program which takes two integers x & y as input, you 1 4
have to compute x/y. If x and y are not integers or if y is zero,
exception will occur and you have to report it.
1 A piece of Java code is given below. You have to complete the code 1 4
0 by writing down the handlers for exceptions thrown by the code. The
exceptions the code may throw along with the handler message are
listed below:

Division by zero: Print "Invalid division".


String parsed to a numeric variable: Print "Format mismatch".
Accessing an invalid index in string: Print "Index is invalid".
Accessing an invalid index in array: Print "Array index is invalid".

MyException: This is a user defined Exception which you need to


create. It takes a parameter param. When an exception of this class is
encountered, the handler should print "MyException[param]", here
param is the parameter passed to the exception class.

Exceptions other than mentioned above: Any other exception except the
above ones fall in this category.
Print "Exception encountered". Finally, after the exception is handled,
print "Exception Handling Completed".

Example: For an exception of MyException class if the parameter value


is 5, the message will look like MyException[5].
1 Write a java program to generate user defined exception using “throw” 1 4
1 and “throws” keyword.
Also Write a java that differentiates checked and unchecked
exceptions. (Mention at least two checked and two unchecked
exception in program).
PART-VI File Handling & Streams
1 Write a program that will count the number of lines in each file that is 1 4, 6
specified on the command line. Assume that the files are text files.
Note that multiple files can be specified, as in "java Line Counts
file1.txt file2.txt file3.txt". Write each file name, along with the
number of lines in that file, to standard output. If an error occurs while
trying to read from one of the files, you should print an error message
for that file, but you should still process all the remaining files.
2 Write an example that counts the number of times a particular 1 4, 6
character, such as e, appears in a file. The character can be specified at
the command line. You can use xanadu.txt as the input file.
3 Write a Java Program to Search for a given word in a File. Also show 1 4, 6
use of Wrapper Class with an example.
4 Write a program to copy data from one file to another file. If the 1 4, 6
destination file does not exist, it is created automatically.
5 Write a program to show use of character and byte stream. Also show 1 4, 6
use of BufferedReader/BufferedWriter to read console input and write
them into a file.
PART-VII Multithreading

1 Write a program to create thread which display “Hello World” 1 5, 6


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. 1 5, 6
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 java program that implements a multi-thread application that 1 5, 6
has three threads. First thread generates random integer every 1 second
and if the value is even, second thread computes the square of the
number and prints. If the value is odd, the third thread will print the
value of cube of the number.
4 Write a program to increment the value of one variable by one and 1 5, 6
display it after one second using thread using sleep() method.
5 Write a program to create three threads ‘FIRST’, ‘SECOND’, 1 5, 6
‘THIRD’. Set the priority of the ‘FIRST’ thread to 3, the ‘SECOND’
thread to 5(default) and the ‘THIRD’ thread to 7.
6 Write a program to solve producer-consumer problem using thread 1 5, 6
synchronization.
PART-VIII Collection Framework and Generic
1 Design a Custom Stack using ArrayList class, which implements 1 5
following functionalities of stack. My Stack
-list ArrayList<Object>: A list to store elements.
+isEmpty: boolean: Returns true if this stack is empty.
+getSize(): int: Returns number of elements in this stack.
+peek(): Object: Returns top element in this stack without removing it.
+pop(): Object: Returns and Removes the top elements in this stack.
+push(o: object): Adds new element to the top of this stack.
2 Create a generic method for sorting an array of Comparable objects. 1 5
3 Write a program that counts the occurrences of words in a text and 1 5
displays the words and their occurrences in alphabetical order of the
words. Using Map and Set Classes.
4 Write a code which counts the number of the keywords in a Java 1 5
source file. Store all the keywords in a HashSet and use the contains ()
method to test if a word is in the keyword set.
Prepared By:
Ms. Dhruvi Gosai

You might also like