Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Reg. No.

Question Paper Code : 17077

B.E. / B.TECH. DEGREE EXAMINATION, APRIL / MAY 2021


Fourth Semester
B.Tech. – Information Technology
19IT402 – JAVA PROGRAMMING
(Regulations: Mepco – R2019)
Duration: 3 Hours Max. : 100 Marks
Answer ALL Questions
PART A – (10  2 = 20 Marks)
BTL, CO

U, CO1 1. Java is a platform independent language. Justify.


A, CO1 2. What is the output of the following code? Justify your answer.
class Test {
float f ;
}
public class Main
{
public static void main(String[] args) {
Test o = new Test();
System.out.println(o.f);}
}
A) Compile Time error B) Run time error C) 0 D) 0.0
U, CO2 3. Give the significance of finalize () method with an example code.
A, CO2 4. What is the output of the following code? Justify your answer.
public class Main
{
public static void main(String[] args) {
int a[]={5,3,6,2,6};
try {
System.out.println(a[5]);
} catch(Exception e)
{
System.out.println(e);

1
17077
}
}
}
A) 6 B) ArrayIndexOutOfBoundsException
C) ArithmeticException D) Compile Error
U, CO3 5. State the purpose of stream filters. How do you use the stream filters in application
development?
A, CO3 6. What will be the output of the following Java program? Justify your answer.
public class Main{
public static void main(String[] args) {
System.out.println("Hello");
System.out.print("Hello");
System.out.println("Hello"); }
}
A) Hello B) HelloHello
HelloHello Hello
C) HelloHelloHello D) Hello
Hello Hello
R, CO4 7. Write down the life cycle of Applet.
R, CO4 8. Choose the correct syntax of drawString() method of Graphics object. Justify your
answer.
A) void drawString(String message, int x, int y)
B) int drawString(String message, int x, int y)
C) void drawString(String message)
D) void drawString(Text message, int x, int y)
U, CO5 9. Distinguish between single threaded programming and Multi-threaded programming.
A, CO5 10. What is the output of the following code?Justify your answer.
public class Main{
public static void main(String[] args) {
Thread t = Thread.currentThread();
System.out.println(t.getPriority());
}
}
A) 0 B) 5 C) 10 D) Compile time Error

2
17077
PART B – (5  16 = 80 Marks)
A,CO1 11. a) i. Design and write a class to represent a Student with the following
members:
Data Members : Roll number, Student name, Mark1, Mark2 and Mark3
Methods:
 To generate the roll number sequentially.
 To Calculate the total marks and percentage
 To display the students details in their descending order of their
percentage
Use the constructor to initialize the data members and create an array of
objects to store and manipulate 5 students’ details. (10 Marks)
U,CO1 11. a) ii. Compare class and interface with an example code. (6 Marks)
OR
A,CO1 11. b) i. Create an abstract class called Shape which has three subclasses namely
Triangle, Rectangle and Circle. Define a method area () in the abstract
class and override this area() method in the three subclasses to calculate
the area for specific object. Use the constructor in both super class and
subclasses to initialize the dimensions of various shapes. (10 Marks)
U,CO1 11. b) ii. State the significance of java packages with an example and explain the
package creation in Java. (6 Marks)

A,CO2 12. a) i. Develop a java code to create custom exception class for the following
scenario: If the withdrawal amount is greater than the balance amount in
the account, raise an exception called “NotSufficientBalanceAmount”.
Also the bank enforces that the account holder should maintain a
minimum amount of Rs.1000 in the account. (10 Marks)
A,CO2 12. a) ii. Write the advantages of exception handling mechanism supported in
JAVA. Write a java program to illustrate how to handle more than one
exception thrown by a piece of java code. (6 Marks)
OR

3
17077
A,CO2 12. b) i. The height of seven students in a class is measured in centimeter and
meter respectively. Two arrays are created to store the details. One
integer type array stores the heights in centimeter and other double type
array stores it in meter as given below.
int[] height_centimetre = new int[] {174,187,163,152,171, 165,178,154};
double[] height_meter = new double[]{1.74,1.87,1.63,1.52,1.71,
1.65,1.78,1.54};
Write a generic java method to sort the heights of different students with
different data types. (10 Marks)
A,CO2 12. b) ii. Write thedifferences between List, Set, and Map in Java. Write a java
program to create a HashSet object called cars that will store different
brands of cars and also iterate the collections in the Hashset. (6 Marks)

A,CO3 13. a) i. Assume that there is a zip file named “java_programs.zip” in your
current working directory “d:\Lab_programs” which contains all types of
files such as .java, .class and .jpeg. Write a Java program to extract the
contents of zip file and place it in a different directory. Also print the
number of files extracted from the zip file. (10 Marks)
U,CO3 13. a) ii. Define the term Stream. List the classes and methods supported in java to
perform Binary input and output operations in a file. (6 Marks)
OR
A,CO3 13. b) i. Design a class called Employee with the data members like Name of the
Employee, Employee Id, Designation and salary. Include the
constructors for initializing the data members and a method to display
the Employee details. Create Employee object and write the object in to a
File. Also read the content of the File and display the Employee details. (10 Marks)
U,CO3 13. b) ii. What do you mean by versioning? Mention the benefits of versioning
along with the various interfaces and classes used in versioning. (6 Marks)

4
17077
U,CO4 14. a) i. Write the concept of Event Driven programming model. State the role of
Adapter classes in event handling with an example code. (8 Marks)
A,CO4 14. a) ii. Design a GUI application for creating “File” and “Edit” as Menu items.
Sub-menu items for “File” may include New, Open, Close, Save and
Print. Sub-menu items for “Edit” may include Cut, Copy, Paste and Find.
Provide an event handler to all the Sub-menu items and when the sub-
menu item is clicked, the name of the sub-menu has to be displayed in
GUI. (8 Marks)
OR
U,CO4 14. b) i. Illustrate the concept of Layout management. With an example code,
explain any two layout management classes and write the steps involved
in creating the instance of layout class and adding controls into the
layout. (8 Marks)
A,CO4 14. b) ii. Develop a swing application for the registration of online courses. The
form should take your name, sex, e-mail id, mobile number and course
name with appropriate controls. Write a Java code to save the above
online course registration details to the Database when the user clicks the
“Register” button. (8 Marks)

U,CO5 15. a) i. State the significance of Thread class and its methods. Write the steps
involved in creating a multi-threaded java program with an example
code. (8 Marks)
A,CO5 15. a) ii. Write a Multi-threaded java program to create two child threads which
prints the Armstrong numbers between the two given ranges. The first
child thread prints the Armstrong numbers between 100 and 300 and the
second child thread prints the Armstrong numbers between 301 and 500. (8 Marks)
OR
U,CO5 15. b) i. How do you set the priorities to thread in Java? Discuss it with an
example code and mention the benefits of it. (8 Marks)
A,CO5 15. b) ii. Write a Java program for producer and consumer problem, where a
producer thread reads a portion of file content and places them into a
queue, while a consumer thread reads and displays them. (8 Marks)

5
17077
6
17077

You might also like