NEW
Font size
WorksheetsVAC - Java -Applets and Servlets
Total questions: 25
Worksheet time: 25mins
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) 66
B) A
C) B
D) 65
Which type of loop is best known for its boolean condition that controls entry to the loop?
A. do-while loop
B. for (traditional)
C. for-each
D. while
What data type would you use for storing the number of students in a class?
boolean
String
double
int
What is the output of the following code snippet?
int i = 0; for(i = 0 ; i < 5; i++)
{ }
System.out.println(i);
A. 5
B. 0
C. 4
D. Compilation Error
Predict the value of k,
int k =10;
k=k+k++;
11
20
21
22
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
B
AC
BC
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 = 2 b = 3 c = 4 d = 1
a = 2 b = 3 c = 4 d = 1
Program does not compile.
a = 1 b = 2 c = 4 d = 2
6.Abbreviate the term HQL?
a. Hibernate Queue Language
b. Hibernate Query Language
c. Hipher Query Language
d. None of the above
5.We need to specify @Inheritance(strategy=InheritanceType.JOINED) in the parent class and @PrimaryKeyJoinColumn annotation in the subclasses.
a. True
b. False
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);
}
}
small
tiny
huge
Compilation fails
int [] nums = {2, 3, 5, 8, 9, 11};
How would you access the fourth element in nums?
nums[4]
nums[3]
nums(4)
nums(3)
which one of the following is true?
runnable interface declares the start method
Thread.start() method is used to move a thread from a new state to the runnable state
Thread.runnable() method is used to move a thread from new state to the runnable state
Thread.run() method is used to move a thread from new state to the runnable state
When the operators are having the same priority, they are evaluated from …………….. …………. in the order they appear in the expression.
right to left
left to right
Any of the order
Depends on the compilor
What is the use of final keyword in Java?
When a class is made final, a sublcass of it can not be created
When a method is final, it can not be overridden.
When a variable is final, it can be assigned value only once.
All of the above
_____ is used to find and fix bugs in the Java programs.
JVM
JRE
JDK
JDB
Evaluate the following Java expression, if x=3, y=5, and z=10:
++z + y - y + z + x++
24
23
20
25
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 Simple Applet
b) A Simple Applet 20 20
c) Compilation Error
d) Runtime Error
import java.awt.*;
import java.applet.*;
public class myapplet extends Applet {
Graphic g;
g.drawString("A Simple Applet", 20, 20);
}
a) 20
b) Default value
c) Compilation Error
d) Runtime Error
What invokes immediately after the start() method and also any time the applet needs to repaint itself in the browser?
a. stop()
b. init()
c. paint()
d. destroy()
4) Which are the common security restrictions in applets?
a. Applets can't load libraries or define native methods
b. An applet can't read every system property
c. Applets can play sounds
d. Both A & B
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. Server
b. Webserver
c. Container
d. Application Server
Which component is responsible for converting bytecode into machine specific code
JVM
JDK
JRE
JIT
Which of the following option leads to the portability and security of Java?
Bytecode is executed by JVM
The applet makes the Java code secure and portable
Use of exception handling
Dynamic binding between objects
Which of the following tool is used to generate API documentation in HTML format from doc comments in source code?
javap tool
javaw command
Javadoc tool
javah command
<class name><Object name>=new <class name>();
This is syntax of creating ______.
class
object
method
function
