CGB1201 – Java Programming
(Regulations 2023)
Time: Two and a half hours Maximum Marks: 80 Marks
PART- A (8 x 2 = 16 Marks)
[Link]. Answer ALL Questions CO BTL
1. State the difference between .class file and .java file. CO1 BTL2
2. Write a Java statement to extract a substring from a string object using the CO1 BTL3
substring () method.
3. What are the different access specifiers in Java? CO2 BTL2
4. Justify how interfaces support multiple inheritance in Java. CO2 BTL4
5. Correct the error(s) if any in the following program: CO3 BTL4
public class Test implements Runnable {
public Test () {
Test task = new Test();
new Thread(task).start();
}
public void run() {
[Link]("test");
}
public static void main(String[] args) {
new Test();
}}
6. What is the difference between byte streams and character streams in CO3 BTL4
Java?
7. Analyze how the repaint () method in AWT ensures proper rendering of CO4 BTL4
graphics in a window. Why is it preferred over directly calling the paint ()
method?
8. Point out the various Action Event Class Constructors in java. CO4 BTL2
PART – B (4 x 16 = 64 Marks)
11.a) a. Explain in detail variables and operators in Java with an example? CO1 BTL3 16
(OR)
1
11.b) (i) Write a Java program to display the day of the week based on a number CO1 BTL3 10
(1 for Monday, 2 for Tuesday, etc.) using a switch statement.
(ii) Write a Java program to find the largest number among three given CO1 BTL3 6
numbers using if-else.
12.a) Write a Java program for the given scenario: CO2 BTL3 16
(i) Create a class named College Course that includes data fields that hold
the department (for example, ENG), the course number (for example, 101),
the credits (for example, 3), and the fee for the course (for example, $360).
All of the fields are required as arguments to the constructor, except for the
fee, which is calculated at $120 per credit hour. Include a display() method
that displays the course data.
(ii) Create a subclass named LabCourse that adds $50 to the course fee.
Override the parent class display () method to indicate that the course is a
lab course and to display all the data. Write a main class Use Course that
reads the course information. If the user enters a class in any of the
following departments, create a LabCourse: BIO, CHM, CIS, or PHY. If
the user enters any other department, create a College Course that does not
include the lab fee. Then display the course data.
(OR)
12.b) A boy has his money deposited $1000, $1500 and $2000 in banks-Bank A, CO2 BTL3 16
Bank B and Bank C respectively. We have to print the money deposited by
him in a particular [Link] a class 'Bank' with a method 'getBalance'
which returns 0. Make its three subclasses named 'BankA', 'BankB' and
'BankC' with a method with the same name 'getBalance' which returns the
amount deposited in that particular bank. Call the method 'getBalance' by
the object of each of the three banks.
13.a) (i). Describe different types of exceptions in Java. Provide examples. CO3 BTL3 10
(ii). Demonstrate the throws keyword with an example program. CO3 BTL3 6
(OR)
13.b) (i)Explain the auto-closing feature in file handling with a program. CO3 BTL3 8
2 X31136
(ii) Write a program to illustrate file read operations using streams. CO3 BTL3 8
14.a) (i) Create a Java program using AWT to design a simple calculator that CO4 BTL3 10
performs addition of two numbers. Include Text Field for inputs and Button
to calculate.
(ii) Explain the use of Border Layout in AWT with an example. CO4 BTL3 6
(OR)
14.b) (i) What is Java Swing, and how is it different from AWT? CO4 BTL3 8
(ii) Explain the use of JCheckBox, JRadioButton, and JToggleButton in CO4 BTL3 8
Swing applications.
******************
3 X31136