Nitte Meenakshi Institute of Technology: Department of Computer Science and Engineering
Nitte Meenakshi Institute of Technology: Department of Computer Science and Engineering
Question Bank(2016-17)
Semester: 6th Semester CSE Date:21/03/2017
Subject and Code: Application Development using JAVA 14CS61
Name of Faculty : B.A Mohan/ Afroz Pasha/Ramyashree B R/Asst. Prof/ CSE,
3 Create a Java Class “Shape” with constructor to initialize the one 8 (1,3) 3
parameter “dimension”. Now create three sub classes of Shape with
following methods . 8M
(i) “Circle” with methods to calculate the area and circumference of the
circle with dimension as radius.
(ii) “Square” with methods to calculate the area and length of diagonal of
the square with dimension as length of one side.
(iii) “Sphere” with methods to calculate the volume and surface area of the
sphere with dimension as radius of the sphere.
Write appropriate main method to create object of each class and test every
method.
7 Illustrate the use of static method in Java with an appropriate example. 5 (1,3) 3
8 Illustrate the concept of inner classes with an example. 6 (1,3) 3
10 Demonstrate the two uses of super in JAVA with example programs 6 (1,3) 3
11 Define a superclass Room with fields; length, breadth and a method area to 8 (1,3) 3
find area of the room .Inherit this superclass members into another class
called BedRoom. The class BedRoom must have a method to find volume of
the Room. Create an object of BedRoom class & invoke the methods area()
and volume() for the object created.
12 What do you mean by method overriding. Give an example where a subclass 5 (1,3) 1,2
overrides display() method of a superclass.
13 Compare and contrast the following 6 (1,3) 1
i)Method overriding and method overloading
ii)abstract and final classes
14 Override area() method of Figure class to find area of a rectangle and area 6 (1,3) 3
of a triangle using run-time polymorphism concept. Figure class has two
fields; a parameterized constructor & an area() function
15 Define an Abstract class figure with an abstract method area () & extend 10 (1,3) 3
this class to find area of a rectangle & a triangle.
16 Implement an abstract class named Person and two subclasses named 10 (1,3) 3
Student and Employee in Java. A person has a name, address, phone
number and e-mail address. A student has a class status (freshman,
sophomore, junior or senior). Define the status as a constant. An employee
has an office, salary and date-hired. Implement the above classes in Java.
Provide Constructors for classes to initialize private variables. Override the
toString method in each class to display the class name and the person’s
name. Write an application to create objects of type Student and Employee
and print the person’s name and the class name of the objects.
17 What is Dynamic method dispatch? Explain with an example program. 6 (1,3) 1,2
18 Declare a class called employee having employee_id and employee_name as 7 (1,3) 3
members. Extend class employee to have a subclass called salary having
designation and monthly_salary as members.
Define following:
- Required constructors
- A method to find and display all details of employees drawing salary
more than Rs. 20000/-.
- Method main for creating an array for storing these details given as
command line arguments and showing usage of above methods
19 Describe the following features of java: 7 (1,3) 1
1)Multithreaded,2)Architecture-neutral 3)Interpreted 4)High performance
5) Distributed 6) Portable 7) Dynamic
20 Explain & illustrate by examples use of final, finally and method finalize. 6 (1,3) 1,3
21 Illustrate by examples the three uses of final keyword in JAVA 6 (1,3) 1,3
22 Declare a class called book having author_name as private data 8 (1,3)
member. Extend book class to have two sub classes called book_publication
& paper_publication.Each of these classes have private member called title.
Write a completeprogram to show usage of dynamic method dispatch
(dynamic polymorphism) to display book or paper publications of given
author.Use command line arguments for inputting data.
Sl UNIT 2 Marks (CO,PO) Bloom’s
No. level
1 Define an interface area and implement this interface to find area of 6 (2,3) 3
a rectangle & a triangle.
2 Give the general syntax for defining and implementing an interface 5 (2,3) 1,3
with an example
3 Declare an Interface Intstack with push() pop() methods. Implement 8 (2,3) 3
this Interface in a Fixedstack class. Create two objects of Fixedstack
class & perform push(),pop operations.
4 Explain interface in JAVA. How do interfaces support 5 (2,3) 1,2
polymorphism?
5 Demonstrates a program that illustrates interface inheritance. 6 (2,3) 3
Interface P is extended by P1and P2. Interface P12 inherits from
both P1 and P2.Each interface declares one constant and one
method. class Q implements P12.Instantiate Q and invoke each of
its methods. Each method displays one of the constants.
6 Differentiate between abstract class and interface. 4 (2,3) 1,2
7 Give general form of the package statement. Give an example 5 (2,3) 1,2
package creation statement.
8 Give general form of a multileveled package statement. What is the 7 (2,3) 1,2
significance of the CLASSPATH environment variable in
creating/using a package?
9 Give the general form of the import statement. Illustrate a Java 6 (2,3) 1,2
program that creates a package and uses it.
a();
System.out.println("main: catch");
} finally {
System.out.println("main: finally");
}
}
public static void a() {
try {
int x=8,y=0;
int z=x/y;
System.out.println("value of z="+z);
} catch(NumberFormatException e) {
System.out.println("method a:catch");
} finally {
System.out.println("method a:finally");
} }}
Sl UNIT 3 Marks (CO,PO) Bloom’s
No. level
1 Distinguish between process-based multitasking & thread-based 4 (3, 2,3) 1
multitasking
2 What is a thread? Describe the complete life cycle of thread with 6 (3, 2,3) 1,2
example.
3 Illustrate the two different ways of creating a thread in JAVA 6 (3, 2,3) 3
4 Design a program to create two threads so one thread will print odd 6 (3, 2,3) 3
numbers where as second thread will print even numbers between 1
to 20 numbers
5 Develop a java program to Create a main thread displaying 5 (3, 2,3) 3
numbers from 1 to 5.Change the name of the main thread to
MyThread & display new thread name, its priority & the name of
its group
6 Demonstrate a JAVA multithreaded program for 6 (3, 2,3) 3
i)isAlive( ) ii)join( )
7 Develop a program to spawn three threads named ‘One’, ’Two’ 7 (3, 2,3) 3
and ‘Three’. Threads display the numbers from 1 to 3. Display the
name, priority & group name of threads
8 Write a java program to demonstrate two threads at different 7 (3, 2,3) 3
priorities. The threads should be started & allowed to run for ten
seconds. Each thread should execute a loop. After 10 seconds the
main thread should stop both threads and should display the
number of times each thread made it through the loop
9 What is meant by ‘race condition’ of threads in java? Illustrate this 8 (3, 2,3) 1,3
with the help of an example. How to overcome race condition?
Modify your code for this
10 Explain Inter-thread communication. How to achieve inter thread 6 (3, 2,3) 1,3
communication in JAVA?
11 Write a java program for synchronized inter-thread communication 8 (3, 2,3) 3
of producer/consumer problem. It has four class :Q, the queue that
need to be synchronized; producer, the threaded object producing
queue entries; consumer, the threaded object consuming queue
entries ; and pc, the class that creates the single queue, producer&
consumer
12 Demonstrate a JAVA multithreaded program for suspending, 6 (3, 2,3) 3
resuming and stopping a thread.