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

Set 2

The document consists of multiple-choice questions and programming tasks related to Java concepts, including truncation, exception handling, output of specific code snippets, and practical programming exercises. It covers topics such as floating-point operations, array manipulation, string comparison, and data structure conversions. Additionally, it includes requests for writing specific Java programs like checking anagrams and implementing merge sort.

Uploaded by

ravi kumar Cheva
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)
3 views3 pages

Set 2

The document consists of multiple-choice questions and programming tasks related to Java concepts, including truncation, exception handling, output of specific code snippets, and practical programming exercises. It covers topics such as floating-point operations, array manipulation, string comparison, and data structure conversions. Additionally, it includes requests for writing specific Java programs like checking anagrams and implementing merge sort.

Uploaded by

ravi kumar Cheva
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

1) What is Truncation in Java?

a) Floating-point value assigned to a Floating type


b) Floating-point value assigned to an integer type
c) Integer value assigned to floating type
d) Integer value assigned to floating type
2) public class Test {
public static void main(String[] args) {
try {
throw new IOException("Hello");
} catch(IOException | Exception e) {
[Link]([Link]());
}
}
}
How many issues are there in the above code
a) 1
b) 2
c) 3
d) 4
3). What will be the output of the following Java program?
class output {
public static void main(String args[])
{
double a, b,c;
a = 3.0/0;
b = 0/4.0;
c=0/0.0;
[Link](a);
[Link](b);
[Link](c);
}
}
a) NaN
b) Infinity
c) 0.0
d) all of the mentioned
4) What will be the output of the following Java code?
class box
{
int width;
int height;
int length;
}
class main
{
public static void main(String args[])
{
box obj = new box();
[Link] = 10;
[Link] = 2;
[Link] = 10;
int y = [Link] * [Link] * [Link];
[Link](y);
}
}
a) 100
b) 400
c) 200
d) 12
5) What will be the output of the following Java program?
class Output
{
public static void main(String args[])
{
int arr[] = {1, 2, 3, 4, 5};
for ( int i = 0; i < [Link] - 2; ++i)
[Link](arr[i] + " ");
}
}
a) 1 2 3 4 5
b) 1 2 3 4
c) 1 2
d) 1 2 3
6) Write Java program that checks if two Arrays contains same elements.
7) Write a Java program to check if two given strings are anagrams of each other.
8) How can you find string in text file in java?
9) How to convert a List of objects into a Map by considering duplicated keys and
store them in sorted order?
10) Write a program for Merge sort?

You might also like