SET-9
1)import java.util.*;
class demo1 {
public static void
main(String[] args)
{
Vector v = new Vector(20);
System.out.println(v.capacity());
System.out.println(v.size());
}
}
A.20,0
B.22,2
C.20,1
D.20,2
2)
public class testmeth
{
static int i = 1;
public static void main(String args[])
{
System.out.println(i+” , “);
m(i);
System.out.println(i);
}
public void m(int i)
{
i += 2;
}
}
A.1 , 3
B.3 , 1
C.1 , 1
D.1 , 0
3)
Among these expressions, which is(are) of type String?
(A) “0”
(B) “ab” + “cd”
(C) ‘0’
(D) Both (A) and (B) above
(E) (A), (B) and (C) above.
4)
class eq
{
public static void main(String args[])
{
String s1 = “Hello”;
String s2 = new String(s1);
System.out.println(s1==s2);
}
}
(A) true
(B) false
(C) 0
(D) 1
5)
Use the following declaration and initialization to evaluate
the Java expressions
int a = 2, b = 3, c = 4, d = 5;
float k = 4.3f;
System.out.println( – -b * a + c *d – -);
(A) 21
(B) 24
(C) 28
(D) 26
(E) 22.
6)
class prob1{
int puzzel(int n){
int result;
if (n==1)
return 1;
result = puzzel(n-1) * n;
return result;
}
}
class prob2{
public static void main(String args[])
{
prob1 f = new prob1();
System.out.println(” puzzel of 6 is = ” + f.puzzel(6));
}
}
(A) 6
(B) 120
(C) 30
(D) 720
7)
In Java, a try block should immediately be followed by one or more
……………….. blocks.
(A) Throw
(B) Run
(C) Exit
(D) Catch
8)
public class Compute {
public static void main (string args [ ])
{
int result, x ;
x = 1 ;
result = 0;
while (x < = 10) {
if (x%2 == 0) result + = x ;
+ + x ;
}
System.out.println(result) ;
}
}
(A) 55
(B) 30
(C) 25
(D) 35
9)
Which of the following statements about Java Threads is correct?
(A) Java threads don’t allow parts of a program to be executed in
parallel
(B) Java is a single-threaded language
(C) Java’s garbage collector runs as a high priority thread
(D) Ready, running and sleeping are three states that a thread can
be in during its life cycle
10)
In a class definition, the special method provided to be called to
create an instance of that class is known as a/an
(A) Interpreter
(B) Destructor
(C) Constructor
(D) Object
No comments:
Post a Comment