WorksheetsJava Screening Test
Total questions: 40
Worksheet time: 36mins
Predict the output.
[A, B, C]
[1, 2, 3]
{A=1, B=2, C=3}
[A=1, B=2, C=3]
Can I store duplicate values in a Map?
Yes
No
Which of these packages contain classes and interfaces used for input & output operations of a program?
java.lang
java.io
java.util
java.stream
Which of the followings are predefined streams in Java?
System.in
System.out
System.err
All the above
What is the return type of readObject() method?
void
boolean
String
Object
Predict the output.
Java World World
JavaJava World
Java World Java World
Compile Time Error
Predict the output.
abcdefabcDEF
abcabcDEFDEF
abcdefabcdef
None of the above
Which of the following is mutable object in Java?
String
StringBuffer
Both A & B
None of the above
What is the return type of charAt() method in String Class?
char
int
byte
boolean
What is the return type of split() method of String class?
String
Array
String[]
Object[]
How to ensure only one thread has access to the shared object at a given point in time with multiple threads?
synchronized blocks in thread class
synchronized method in thread class
synchronized blocks in thread class
synchronized method in shared object class
synchronized blocks in shared object class
synchronized method in thread class
synchronized blocks in shared object class
synchronized method in shared object class
Predict the output
[3, 5]
[3, 2]
[3, 2, 5]
[3, 5, 2]
What will be the output of following program?
alpha beta a b
beta alpha b b
alpha beta b b
beta alpha a b
Which of the following is index based collection?
List
Set
SortedSet
Map
Which of the following is the method to add key and value pair in a Map collection?
add()
put()
save()
insert()
What is the return type of hasNext() method of
an iterator interface?
int
boolean
Object
void
An application module has to simulate train ticketing system to handle confirmed tickets, general Waiting List, Tatkal Waiting List, RAC etc
ArrayList
HashMap
TreeMap
PriorityQueue
Fill the Code:
Map<Integer,String> map=new HashMap<Integer,String>();
map.put(1,"One");
map.put(4,"Four");
map.put(2,"Two"); Set<Map.Entry<Integer,String>> set=map.______________
iterator()
setEntry()
enterySet()
enteries()
Which of the below is/are valid identifier with the main method?
public
private
static
this
1. class main_class
2. {
3. public static void main(String args[])
4. {
5. int y = 10;
6. if (y == 10)
7. {
8. int y = 11;
9. System.out.println(y);
10. }
11. }
12. }
Compilation error
10
11
Run time error
class KIET_Test {
int x;
}
class Main {
public static void main(String args[]) {
KIET_Test t = new KIET_Test();
System.out.println(t.x);
}
}
garbage value
0
compiler error
runtime error
What is the output of the following program?
"ABC"
"ACB"
"BAC"
"CBA"
What is the output of the following code snippet?
apple, banana, cherry
cherry, banana, apple
banana, apple, cherry
apple, cherry, banana
What will be the output of following program?
45
18
56
30
What will be the output of following program?
HELLO WORLD JAVA
hello world java
HELLO WORLD
HELLOWORLD
What will be the output of following program?
Derived
Derived
Base
Base
Base
Derived
Derived
Bae
Derived
Base
Derived
Derived
What will be the output of following program?
0
20
compile time error
Run time Error
correct execution process in Java
load->edit->compile->verify->execute
edit->load->compile->execute->verify
edit->compile->load->verify->execute
verify->edit->compile->load->execute
What is the extension of compiled java classes?
.class
.js
.txt
.java
JVM is _____
code dependent
code independent
platform dependent
platform independent
Which component is used to compile, debug and execute java program?
JVM
JDK
JIT
JRE
Which kind of loop would be used?
I need a program that will keep letting me add a monthly payment for 12 months.
FOR Loop
WHILE Loop
Which kind of loop would be used?
I need a guessing game program that will let me keep guessing until I get the right answer.
FOR Loop
WHILE Loop
Which kind of loop would be used?
I need a program that will keep letting me add money to a piggy bank until I get to $100.
FOR Loop
WHILE Loop
for (int count = 1; count <= 10; count++) {
System.out.println("Welcome to Java");
System.out.println("Welcome to Java");
}
System.out.println("Welcome to Java");
}
System.out.println("Welcome to Java");
}
FOR loops are
loops which run an unknown number of times
loops which run for a specific number of times
the same as if statements
not part of programming
How many times does this print a * ?
4
5
6
7
Which of the following is/are advantages of packages?
Packages avoid name clashes
Classes, even though they are visible outside their package, can have fields visible to packages only
We can have hidden classes that are used by the packages, but not visible outside.
All of the above
