WorksheetsTest 2
Total questions: 36
Worksheet time: 42mins
Enter your Register number
(not a question but required xD)
{1=C, 2=JavaEE, 4=Python, 3=PHP}
{1=C, 2=JavaSE, 3=Python, 4=PHP}
{1=C, 2=JavaEE, 3=Python, 4=PHP}
{1=C, 2=JavaSE,2=JavaEE, 3=Python, 4=PHP}
NullPointerException
-Entries are not organized as key/value pairs.
-Duplicate entries are rejected.
Which interface of the java.util package offers the specified behavior?
List
Map
Set
None of the above
List listNames = new ArrayList();
listNames.add("Tom");
listNames.add("Mary");
listNames.add("Peter");
String name2 = (String) listNames.get(1);
System.out.println(name2);
What is the output of the above code
Tom
Mary
Peter
raises Exception
Which of these interface is not part of Java’s collection framework?
List
Sorted List
Set
Sorted Map
Which of these return type of hasNext() method of an iterator?
Integer
Double
Boolean
Collections Object
Which of these methods deletes all the elements from invoking collection?
clear();
reset();
delete();
remove();
String s1 = "hello";
String s2 = new String("hello");
if (s1 == s2) System.out.print("Hey");
else System.out.print("Yo");
What is the output?
Hey
Yo
There is no output.
This code will not compile.
String s = "whatever".substring(1,4);
What is the value of s?
"hate"
"hat"
"whate"
"what"
StringIndexOutOfBoundsException
int x = "bob".compareTo("Bob");
if (x>=0) System.out.print("Good");
else System.out.print("Bad");
What is the output?
Good
Bad
There is no output.
This code will not compile.
String s = "cool cat".substring(6);
What is the value of s?
"cat"
"at"
"cool c"
This code does not compile.
StringIndexOutOfBoundsException
Which of the following is FALSE about arrays on Java
A java array is always an object
Length of array can be changed after creation of array
Arrays in Java are always allocated on heap
Find the output
class Test {
public static void main(String args[]) {
int arr[2];
System.out.println(arr[0]);
System.out.println(arr[1]);
}
}
Compile error
Exception
Garbage Value
Garbage Value
0
0
Find the output
class Test {
public static void main(String args[]) {
int arr [ ] = new int[2];
System.out.println(arr[0]);
System.out.println(arr[1]);
}
}
Compile error
Exception
Garbage Value
Garbage Value
0
0
What is the length of the following array: byte[] data = { 12, 34, 9, 0, -62, 88 };
1
5
6
12
class Demo1
{
public static void main(String args[])
{
int i[] = new int[10];
System.out.println(i[10]);
}
}
0
Garbage Value
Out-of-bounds exception
Error
Output of following Java program?
class Test{
public static void main (String[] args) {
int arr1[] = {1, 2, 3};
int arr2[] = {1, 2, 3};
if (arr1 == arr2)
System.out.println("Same");
else
System.out.println("Not same");
}}
Same
Not same
Error
Output of following Java Program?
Derived::show() called
Base::show() called
Run time Error
Compilation Error
Which inheritance in java programming is not supported
Multiple inheritance using classes
Multiple inheritance using interfaces
Multilevel inheritance
Single inheritance
What will be the output of the following Java program?
None of the mentioned
0
120
1
Output of following Java program?
Base
Derived
Derived
Base
Base
Derived
Base
Derived
Base
Compiler Error
What is subclass in java?
A subclass is a class that extends another class
A subclass is a class declared inside a class
Both above.
None of the above.
What will be the output?
An Exception is caught in method1.
An Exception is caught in method2.
An Exception is caught in method3.
The program crashes.
Which of these is caused by integer division by zero?
ArithmeticException
ArrayIndexOutOfBoundsException
MathException
DivisionByZeroException
If sc = new Scanner(System.in) and x = sc.nextInt(), which of these is thrown if the user inputs the String "x"?
NullPointerException
StringIndexOutOfBoundsException
InputMismatchException
IllegalArgumentException
How to create our own exception
using 'throw' keyword
using 'throws' keyword
using 'finally' keyword
using 'throwable' keyword
Choose the CORRECT exception
String department="JTMK";
Integer no=Integer.parseInt(department);
ArithmeticException
NullPointerException
NumberFormatException
ArrayIndexOutOfBoundsException
It is a Java specification that provides certain functionality and standard to ORM tools.
Hibernate
JPA
Dev Tools
Spring Data
it contains information of configuration for the maven to build the project such as dependencies, build directory, source directory, test source directory, plugin etc.
maven wrapper configuration
application.properties
pom.xml file
application.xml
Which of the following protocol is used by RESTful web services as a medium of communication between client and server?
HTTP
FTP
Gopher
None of the Above
if I want to fetch some data from the Database which http method should be used?
Get
Put
Post
Delete
