0% found this document useful (0 votes)
5 views3 pages

It 251

Uploaded by

jpatel6125
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)
5 views3 pages

It 251

Uploaded by

jpatel6125
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/ 3

Firefox https://examcloud.in/epn/reports/exam-qpaper.

php

Exam Date & Time: 18-Jul-2023 (09:15 AM - 12:30 PM)

CHAROTAR UNIVERSITY OF SCIENCE AND TECHNOLOGY

University Examination July-2023


B.Tech (IT)-III
09:15 a.m. to 12:30 p.m.
Java Programming [IT251]
Marks: 70 Duration: 195 mins.

Section-I
Answer all the questions. Section Duration: 40 mins

1 Automatic type conversion is possible in which of the possiblecases?


(1)
1) Int to long 2) Long to double 3) Float to short 4) Int to byte

2 Find the output of the following code.


int Integer = 24;
char String = 'P';
System.out.print(Integer); (1)
System.out.print(String);

1) Compile error 2) Throws Exception 3) P 4) 24P

3 What is the correct syntax to declare a variable in Java?


a) var name;
b) int name;
c) variable name; (1)
d) declare name;

1) a 2) b 3) c 4) d

4 What is the output of the following code snippet?


int x = 5;
int y = 2;
System.out.println(x / y); (1)

1) 3.5 2) 2.5 3) 2 4) 2.0

5 Which keyword is used to define a constant in Java?


(1)
1) Final 2) Const 3) static 4) constant

6 What is the output of the following code snippet?


String name = "Java";
System.out.println(name.length()); (1)

1) 0 2) 4 3) 3 4) 1

7 Which loop is executed at least once, even if the condition isfalse?


(1)
1) For loop 2) do-while loop 3) While loop 4) foreach loop

8 What is the output of the following code snippet?


int num = 10;
System.out.println(num++); (1)

1) 9 2) 10 3) 11 4) Compile time error

9 Which keyword is used to exit from a loop in Java?


(1)

1 of 3 10-08-2023, 10:22
Firefox https://examcloud.in/epn/reports/exam-qpaper.php

1) exit 2) stop 3) break 4) continue

10 Which operator is used for concatenating strings in Java?


(1)
1) + 2) & 3) * 4) /

11 Which keyword is used to define a superclass in Java?


(1)
1) super 2) this 3) extends 4) implements

12 What is the correct syntax to create an array in Java?


(1)
int[] arr = [1, 2, int arr[] = {1, 2, array arr = new int arr = [1, 2,
1) 2) 3) 4)
3]; 3}; int[3]; 3];

13 Which of the following statements best describes a lambdaexpression in Java?

A lambda A lambda A lambda


A lambda
expression is an expression is a expression is a
expression is a (1)
anonymous predefined Java way to define
1) method with a 2) 3) 4)
function that can keyword used to multiple
single
be treated as a define anonymous constructors for a
statement.
value. classes. class.

14 What is the default value of an integer variable in Java?


(1)
1) 0 2) 1 3) -1 4) null

15 What is the purpose of using the 'import' statement in Java?

It is used to include a It is used to It is used to


It is used to (1)
class or interface define a specify the
1) 2) 3) 4) create objects
from another package in superclass of a
of a class.
package. Java. class.

16 When is the object created with new keyword?


(1)
1) At Compile time 2) Depends on the code 3) At runtime 4) None

17 Which keyword is used to prevent a variable from being modified inJava?


(1)
1) volatile 2) constant 3) static 4) final

18 What is an object in Java?

A method that A collection of An instance of a A reserved word (1)


1) performs a 2) related 3) class that has state 4) used to define
specific task. variables. and behavior. variables.

19 Which event listener interface is used to handle mouse events inJava GUI?
(1)
1) MouseListener 2) ActionListener 3) KeyListener 4) WindowListener

20 What is multithreading?

The ability of a The ability of a


The ability of a None of (1)
program to run program to run
1) program to run multiple 2) 3) 4) the
multiple tasks in multiple tasks in
tasks simultaneously. above.
parallel. the same thread.

Section-II
Answer 5 out of 8 questions.

1 Write a Java code snippet to demonstrate the use of exceptionhandling. Include a try-catch block to
handle a specific exceptionand provide a brief explanation of the code. (5)

2 Explain the difference between method overloading and methodoverriding in Java. Provide an example (5)

2 of 3 10-08-2023, 10:22
Firefox https://examcloud.in/epn/reports/exam-qpaper.php

for each.

3 What are the access modifiers available in Java? Briefly explaineach one with their respective visibility
scope. (5)

4 Evaluate the advantages and disadvantages of using the ArrayListclass over the Array data structure in
Java. Consider factors suchas dynamic resizing, flexibility, and memory management. Justifyyour answer
(5)
with appropriate reasoning.

5 Analyze the following Java code snippet and identify any syntaxerrors or logical issues. Provide the
necessary corrections withexplanation.

public class Circle {


public Circle(double r) {
double radius;
this.radius = this.r;
}
public double calculateArea() { (5)
return 3.14 * radius * radius;
}
public static void main(String[] args) {
Circle c = new Circle(5);
System.out.println("The area of the circle is: " +c.calculateArea());
}
}

6 Write a Java program to calculate the factorial of a given numberusing a recursive function. Include
appropriate comments in yourcode and test it with different inputs. (5)

7 Write a Java program that takes a list of strings as input from theuser and sorts them in alphabetical order
using lambda expressions.Display the sorted list to the user. (5)

8 Differentiate String, StringBuilder and StringBuffer Class indetail.


(5)

Section-III
Answer all the questions.

1 Explain the concept of object-oriented programming in Java. Write aJava program to demonstrate the
implementation of inheritance andpolymorphism. Include comments to explain your code. (4)

2 Explain Thread Life-cycle with all of its stages in detail.


(7)

3 Write a Java program that reads data from a text file called"input.txt" and writes it to another text file
called "output.txt".Make sure to handle any potential I/O exceptions. (7)

4 a "String Objects are immutable". Justify the statement withappropriate example.


(7)

[OR]
b
Develop a Java program to create a graphical user interface (GUI)that includes a button and a text field.
Implement an event handlerusing a lambda expression, so that when the button is clicked, thetext field (7)
displays a predefined message. Include appropriatecomments in your code.

-----End-----

3 of 3 10-08-2023, 10:22

You might also like