wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

VAC - Java -Applets and Servlets

Total questions: 25

Worksheet time: 25mins

Name
Class
Date
1.

What is the output of the below Java code snippet?

char ch = 'A';//ASCII 65

int a = ch + 1;

ch = (char)a;

System.out.println(ch);

a)

A) 66

b)

B) A

c)

C) B

d)

D) 65

2.

Which type of loop is best known for its boolean condition that controls entry to the loop?

a)

A. do-while loop

b)

B. for (traditional)

c)

C. for-each

d)

D. while

3.

What data type would you use for storing the number of students in a class?

a)

boolean

b)

String

c)

double

d)

int

4.

What is the output of the following code snippet?

int i = 0; for(i = 0 ; i < 5; i++)

{ }

System.out.println(i);

a)

A. 5

b)

B. 0

c)

C. 4

d)

D. Compilation Error

5.

Predict the value of k,

int k =10;

k=k+k++;

a)

11

b)

20

c)

21

d)

22

6.

class exception_handling

{ public static void main(String args[])

{ try

{ int a, b;

b = 0;

a = 5 / b;

System.out.print("A");

} catch(ArithmeticException e)

{ System.out.print("B");

}

finally

{ System.out.print("C");

}

}

}

a)

A

b)

B

c)

AC

d)

BC

7.

Find the output for the following.

public class IncDec

{

public static void main(String s[])

{

int a = 1;

int b = 2;

int c;

int d;


c = ++b;

d = a++;


c++;


System.out.println("a = " + a);

System.out.print("b = " + b);

System.out.println("c = " + c);

System.out.print("d = " + d);

}

}

a)

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

b)

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

c)

Program does not compile.

d)

a = 1 b = 2 c = 4 d = 2

8.

6.Abbreviate the term HQL?

a)

a. Hibernate Queue Language

b)

b. Hibernate Query Language

c)

c. Hipher Query Language

d)

d. None of the above

9.

5.We need to specify @Inheritance(strategy=InheritanceType.JOINED) in the parent class and @PrimaryKeyJoinColumn annotation in the subclasses.

a)

a. True

b)

b. False

10.

What will be the output of the program?

class Test

{

public static void main(String [] args)

{

int x=20;

String sup = (x < 15) ? "small" : (x < 22)? "tiny" : "huge";

System.out.println(sup);

}

}

a)

small

b)

tiny

c)

huge

d)

Compilation fails

11.

int [] nums = {2, 3, 5, 8, 9, 11};

How would you access the fourth element in nums?

a)

nums[4]

b)

nums[3]

c)

nums(4)

d)

nums(3)

12.

which one of the following is true?

a)

runnable interface declares the start method

b)

Thread.start() method is used to move a thread from a new state to the runnable state

c)

Thread.runnable() method is used to move a thread from new state to the runnable state

d)

Thread.run() method is used to move a thread from new state to the runnable state

13.

When the operators are having the same priority, they are evaluated from …………….. …………. in the order they appear in the expression.

a)

right to left

b)

left to right

c)

Any of the order

d)

Depends on the compilor

14.

What is the use of final keyword in Java?

a)

When a class is made final, a sublcass of it can not be created

b)

When a method is final, it can not be overridden.

c)

When a variable is final, it can be assigned value only once.

d)

All of the above

15.

_____ is used to find and fix bugs in the Java programs.

a)

JVM

b)

JRE

c)

JDK

d)

JDB

16.

Evaluate the following Java expression, if x=3, y=5, and z=10:

++z + y - y + z + x++

a)

24

b)

23

c)

20

d)

25

17.

import java.awt.*;

import java.applet.*;

public class myapplet extends Applet {

public void paint(Graphics g) {

g.drawString("A Simple Applet", 20, 20);

}

}

a)

a) A Simple Applet

b)

b) A Simple Applet 20 20

c)

c) Compilation Error

d)

d) Runtime Error

18.

import java.awt.*;

import java.applet.*;

public class myapplet extends Applet {

Graphic g;

g.drawString("A Simple Applet", 20, 20);

}

a)

a) 20

b)

b) Default value

c)

c) Compilation Error

d)

d) Runtime Error

19.

What invokes immediately after the start() method and also any time the applet needs to repaint itself in the browser?

a)

a. stop()

b)

b. init()

c)

c. paint()

d)

d. destroy()

20.

4) Which are the common security restrictions in applets?

a)

a. Applets can't load libraries or define native methods

b)

b. An applet can't read every system property

c)

c. Applets can play sounds

d)

d. Both A & B

21.

In Servlet Terminology what provides runtime environment for JavaEE (j2ee) applications. It performs many operations that are given below

1. Life Cycle Management

2. Multithreaded support

3. Object Pooling

4. Security etc.

a)

a. Server

b)

b. Webserver

c)

c. Container

d)

d. Application Server

22.

Which component is responsible for converting bytecode into machine specific code

a)

JVM

b)

JDK

c)

JRE

d)

JIT

23.

Which of the following option leads to the portability and security of Java?

a)

Bytecode is executed by JVM

b)

The applet makes the Java code secure and portable

c)

Use of exception handling

d)

Dynamic binding between objects

24.

Which of the following tool is used to generate API documentation in HTML format from doc comments in source code?

a)

javap tool

b)

javaw command

c)

Javadoc tool

d)

javah command

25.

<class name><Object name>=new <class name>();

This is syntax of creating ______.

a)

class

b)

object

c)

method

d)

function