1.
How can we connect to database in a web application?
A. 
B. 
C. 
D. 
2.
What is the output of this program?
#include <iostream>
using namespace std;
void fun(int x, int y)
{
x = 20;
y = 10;
}
int main()
{
int x = 10;
fun(x, x);
cout << x;
return 0;
}
A. 
B. 
C. 
D. 
3.
What is the output of the following program?
public class Test implementsRunnable
{
public void run()
{
System.out.printf("%d",3);
}
public static void main(String[] args) throws Interrupted Exception
{
Thread thread = new Thread(new Test());
thread.start();
System.out.printf("%d",1);
thread.join();
System.out.printf("%d",2);
}
}
A. 
B. 
C. 
D. 
4.
. What is the output of the following program?
public class Test
{
public static void main(String[] args)
{
int value = 3, sum = 6 + -- value
int data = --value + ++value / sum++ * value++ + ++sum % value--;
System.out.println(data);
}
}
A. 
B. 
C. 
D. 
5.
What does the following code print?
System.out.println("13" + 5 + 3);
A. 
B. 
C. 
It will give a run-time error
D. 
6.
State true or false for Java Program.
i) Data members of an interface are by default final
ii) An abstract class has implementations of all methods defined inside it.
A. 
B. 
C. 
D. 
7.
Which mechanism is used when a thread is paused running in its critical section and another thread is allowed to enter (or lock) in the same critical section to be executed?
A. 
Inter-thread communication
B. 
Initial-thread communication
C. 
D. 
8.
What is the output of the following program?
public class Test
{
public static void main(String[] args)
{
double data = 444.324;
int value = data;
System.out.println(data);
}
}
A. 
B. 
C. 
D. 
9.
What does the following line of code achieve?
Intent intent = new Intent(FirstActivity.this, SecondActivity.class );
A. 
B. 
Creates an implicit Intent
C. 
Create an explicit Intent
D. 
10.
Class Base {
public final void show() {
System.out.println("Base::show() called");
}
}
class Derived extends Base {
public void show() {
System.out.println("Derived::show() called");
}
}
public class Main {
public static void main(String[] args) {
Base b = new Derived();;
b.show();
}
}
A. 
B. 
C. 
D. 
11.
What is the output of this program?
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
int ran = rand();
cout << ran << endl;
}
A. 
B. 
C. 
D. 
12.
What is the meaning of the following declaration?
int(*p[5])();
A. 
B. 
P is array of pointer to function
C. 
P is pointer to such function which return type is the array
D. 
P is pointer to array of function
13.
What is the output of below code snippet?
double a = 0.02;
double b = 0.03;
double c = b - a;
System.out.println(c);
BigDecimal _a = new BigDecimal("0.02");
BigDecimal _b = new BigDecimal("0.03");
BigDecimal _c = b.subtract(_a);
System.out.println(_c);
A. 
0.009999999999999998
0.01
B. 
0.01
0.009999999999999998
C. 
D. 
0.009999999999999998
0.009999999999999998
14.
Which of these is a super class of Character wrapper?
A. 
B. 
C. 
D. 
15.
What is the output of this program?
class bitwise_operator
{
public static void main(String args[])
{
int a = 3;
int b = 6;
int c = a | b;
int d = a & b;
System.out.println(c + " " + d);
}
}
A. 
B. 
C. 
D. 
16.
What is the error in this code?
byte b = 50;
b = b * 50;
A. 
B cannot contain value 100, limited by its range
B. 
* operator has converted b * 50 into int, which can not be converted to byte without casting
C. 
B cannot contain value 50
D. 
17.
What is the output of this program?
class recursion
{
int func (int n)
{
int result;
result = func (n - 1);
return result;
}
}
class Output
{
public static void main(String args[])
{
recursion obj = new recursion() ;
System.out.print(obj.func(12));
}
}
A. 
B. 
C. 
D. 
18.
What is the output of this program?
class recursion
{
int fact(int n)
{
int result;
if (n == 1)
return 1;
result = fact(n - 1) * n;
return result;
}
}
class Output
{
public static void main(String args[])
{
recursion obj = new recursion() ;
System.out.print(obj.fact(6));
}
}
A. 
B. 
C. 
D. 
19.
What is the difference between servlets and applets?
i. Servlets execute on Server; Applets execute on browser
ii. Servlets have no GUI; Applet has GUI
iii. Servlets creates static web pages; Applets creates dynamic web pages
iv. Servlets can handle only a single request; Applet can handle multiple requests
A. 
B. 
C. 
D. 
20.
Which of the following code retrieves the body of the request as binary data?
A. 
DataInputStream data = new InputStream()
B. 
DataInputStream data = response.getInputStream()
C. 
DataInputStream data = request.getInputStream()
D. 
DataInputStream data = request.fetchInputStream()
21.
Which of these interface abstractes the output of messages from httpd?
A. 
B. 
C. 
D. 
22.
What is the output of this program?
class exception_handling
{
public static void main(String args[])
{
try
{
int a[] = {1, 2,3 , 4, 5};
for (int i = 0; i < 7; ++i)
System.out.print(a[i]);
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.print("0");
}
}
}
A. 
B. 
C. 
D. 
23.
What is the output of this program?
public class Demo
{
public static void main(String[] args)
{
Map<Integer, Object> sampleMap = new TreeMap<Integer, Object>();
sampleMap.put(1, null);
sampleMap.put(5, null);
sampleMap.put(3, null);
sampleMap.put(2, null);
sampleMap.put(4, null);
System.out.println(sampleMap);
}
}
A. 
{1=null, 2=null, 3=null, 4=null, 5=null}
B. 
C. 
D. 
{1=null, 5=null, 3=null, 2=null, 4=null}
24.
What is the output of this program?
import java.util.*;
class Bitset
{
public static void main(String args[])
{
BitSet obj = new BitSet(5);
for (int i = 0; i < 5; ++i)
obj.set(i);
obj.clear(2);
System.out.print(obj.length() + " " + obj.size());
}
}
A. 
B. 
C. 
D. 
25.
#include<iostream>
using namespace std;
class Point {
Point() { cout << "Constructor called"; }
};
int main()
{
Point t1;
return 0;
}
A. 
B. 
C. 
D.