0% found this document useful (0 votes)
92 views

Java

The document discusses Java programming concepts like constructors, inheritance, method overloading and output. Multiple choice questions are provided about compiling and running sample code snippets to test understanding of these concepts.

Uploaded by

mamidi sudeep
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views

Java

The document discusses Java programming concepts like constructors, inheritance, method overloading and output. Multiple choice questions are provided about compiling and running sample code snippets to test understanding of these concepts.

Uploaded by

mamidi sudeep
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 108

1 QuestionText Choice1 Choice2 Choice3 Choice4

What will be the result of compiling the A compilation


following program? error will
public class MyClass { occur at (Line
long var; A compilation A compilation no 2), since
public void MyClass(long param) { var = error will error will the class
param; } // (Line no 1) occur at (Line occur at (2), does not
public static void main(String[] args) { no 1), since since the have a
MyClass a, b; constructors class does constructor The program
a = new MyClass(); // (Line no 2) cannot not have a that takes will compile
} specify a default one argument without
} return value constructor of type int. errors.
3 Which of the following declarations are boolean b = String s = int i = new
correct? (Choose TWO) TRUE; byte b = 256; “null”; Integer(“56”);
4 What will happen when you attempt to
compile and run this code?
abstract class Base{
abstract public void myfunc();
public void another(){
System.out.println("Another method");
}
}

public class Abs extends Base{


public static void main(String argv[]){
Abs a = new Abs();
a.amethod(); The compiler
} The code will will complain
public void myfunc(){ compile but that the
System.out.println("My Func"); The compiler complain at method
} The code will will complain run time that myfunc in the
public void amethod(){ compile and that the Base the Base base class
myfunc(); run, printing class has non class has non has no body,
} out the words abstract abstract nobody at all
} "My Func" methods methods to print it
5
Constructor Constructor Constructor Constructor
class A, B and C are in multilevel inheritance of A executes of C executes of C executes of A executes
hierarchy repectively . In the main method of first, followed first followed first followed first followed
some other class if class C object is created, by the by the by the by the
in what sequence the three constructors constructor of constructor of constructor of constructor of
execute? B and C A and B B and A C and B
6 Consider the following code and choose the
correct option:
package aj; private class S{ int roll;
S(){roll=1;} }
package aj; class T
{ public static void main(String ar[]){ Compilation Compiles and Compiles but Compiles and
System.out.print(new S().roll);}} error display 1 no output diplay 0
7 Here is the general syntax for method
definition:
The The
accessModifier returnType methodName( returnValue returnValue
parameterList ) can be any must be the
{ type, but will same type as
Java statements be the
automatically returnType, The
return returnValue; converted to If the or be of a returnValue
} returnType returnType is type that can must be
when the void then the be converted exactly the
method returnValue to returnType same type as
What is true for the returnType and the returns to the can be any without loss the
returnValue? caller type of information returnType.
8 A) A call to instance method can not be made
from static context.
B) A call to static method can be made from Both are Both are Only A is Only B is
non static context. FALSE TRUE TRUE TRUE
9 Consider the following code and choose the
correct option:
class A{ A(){System.out.print("From A");}} Compiles but
class B extends A{ B(int z){z=2;} throws
public static void main(String args[]){ Compilation Comiples and runtime Compiles and
new B(3);}} error prints From A exception display 3
10 class Sample
{int a,b;
Sample()
{ a=1; b=2;
System.out.println(a+"\t"+b);
}
Sample(int x)
{ this(10,20);
a=b=x;
System.out.println(a+"\t"+b);
}
Sample(int a,int b)
{ this();
this.a=a;
this.b=b;
System.out.println(a+"\t"+b);
}
}
class This2
{ public static void main(String args[])
{
Sample s1=new Sample (100);
}
} 100 100 1 2 1 2 100 100 10 20 1 2 100 1 2 10 20 100
What is the Output of the Program? 10 20 10 20 100 100
11 Consider the following code and choose the
correct option:
class A{ private static void display(){ Compiles and Compiles but
System.out.print("Hi");} throw run doesn't
public static void main(String ar[]){ Compiles and time display Compilation
display();}} display Hi exception anything fails
12 Consider the following code and choose the
correct option: code
package aj; class A{ protected int j; } code compiles but
package bj; class B extends A compiles fine will not
{ public static void main(String ar[]){ and will display compliation j can not be
System.out.print(new A().j=23);}} display 23 output error initialized
13 Consider the following code and choose the
correct option:
class A{ int z; A(int x){z=x;} } Compiles but
class B extends A{ throws run Compiles and
public static void main(String arg){ Compilation time displays None of the
new B();}} error exception nothing listed options
14 class Test{
static void method(){
this.display();
}
static display(){
System.out.println(("hello");
}
public static void main(String[] args){
new Test().method();
}
}
consider the code above & select the proper Runtime compiles but does not
output from the options. hello Error no output compile
15 What will be the result when you try to
compile and run the following code?
private class Base{
Base(){
int i = 100;
System.out.println(i);
}
}

public class Pri extends Base{


static int i = 200;
public static void main(String argv[]){
Pri p = new Pri();
System.out.println(i);
} 100 followed Compile time
} 200 by 200 error 100
16 public class MyClass {
static void print(String s, int i) {
System.out.println("String: " + s + ", int: " +
i);
}

static void print(int i, String s) {


System.out.println("int: " + i + ", String: " +
s);
}

public static void main(String[] args) { String: String int: 27,


print("String first", 11); first, int: 11 String: Int
print(99, "Int first"); int: 99, first String:
} String: Int String first, Compilation Runtime
}What would be the output? first int: 27 Error Exception
17
A) No argument constructor is provided to all
Java classes by default
B) No argument constructor is provided to the
class only when no constructor is defined.
C) Constructor can have another class object
as an argument
D) Access specifiers are not applicable to Only A is B and C is All are
Constructor TRUE All are TRUE TRUE FALSE
18 Consider the following code and choose the
correct option:
class Test{ private static void display(){
System.out.println("Display()");}
private static void show() { display(); Compiles and Compiles but
System.out.println("show()");} prints throws
public static void main(String arg[]){ Compiles and Display() runtime Compilation
show();}} prints show() show() exception error
19 Which of the following sentences is true?
A) Access to data member depends on the
scope of the class and the scope of data
members
B) Access to data member depends only on
the scope of the data members
C) Access to data member depends on the
scope of the method from where it is Only A and C All are Only A is
accessed is TRUE All are TRUE FALSE TRUE
20 Given:
public class Yikes {

public static void go(Long n)


{System.out.print("Long ");}
public static void go(Short n)
{System.out.print("Short ");}
public static void go(int n)
{System.out.print("int ");}
public static void main(String [] args) {
short y = 6;
long z = 7;
go(y);
go(z);
} An exception
} Compilation is thrown at
What is the result? int Long Short Long fails. runtime.
21 System.out.pr System.out.pr System.out.pr System.out.pr
intln(Math.cei intln(Math.flo intln(Math.rou intln(Math.mi
Which of the following will print -4.0 l(-4.7)); or(-4.7)); nd(-4.7)); n(-4.7));
22 Suppose class B is sub class of class A:
A) If class A doesn't have any constructor,
then class B also must not have any
constructor
B) If class A has parameterized constructor,
then class B can have default as well as
parameterized constructor
C) If class A has parameterized constructor
then call to class A constructor should be Only B and C Only A is All are Only A and C
made explicitly by constructor of class B is TRUE TRUE FALSE is TRUE
23 class Order{
Order(){
System.out.println("Cat");
}
public static void main(String... Args){
System.out.println("Ant");
}
static{
System.out.println("Dog");
}
{
System.out.println("Man");
}}
consider the code above & select the proper Dog Man Cat
output from the options. Dog Ant Ant Man Dog Ant Dog Man Ant
24 Consider the following code and choose the
correct option:
class A{ private void display(){ Compiles but Compiles and
System.out.print("Hi");} doesn't throws run
public static void main(String ar[]){ display time Compilation Compiles and
display();}} anything exception fails displays Hi
25
Consider the following code and choose the
correct option:
public class MyClass {
public static void main(String arguments[]) {
amethod(arguments);
}
public void amethod(String[] arguments) {
System.out.println(arguments[0]);
System.out.println(arguments[1]);
}
} prints Hi Compiler Runs but no Runtime
Command Line arguments - Hi, Hello Hello Error output Error
26 package QB;
class Sphere {
protected int methodRadius(int r) {
System.out.println("Radious is: "+r);
return 0;
}
}
package QB;
public class MyClass {
public static void main(String[] args) {
double x = 0.89;
Sphere sp = new Sphere();
// Some code missing
}
} to get the radius value what is the code of methodRadiu sp.methodRa Nothing to Sphere.meth
line to be added ? s(x); dius(x); add odRadius();
27 class One{
int var1;
One (int x){
var1 = x;
}}
class Derived extends One{
int var2;
void display(){
System.out.println("var
1="+var1+"var2="+var2);
}}
class Main{
public static void main(String[] args){
Derived obj = new Derived();
obj.display(); compiles
}} successfully
consider the code above & select the proper but runtime
output from the options. 0,0 error compile error none of these
28 Consider the following code and choose the
correct option:
class Test{ private void display(){
System.out.println("Display()");}
private static void show() { display(); Compiles and Compiles but
System.out.println("show()");} prints throws
public static void main(String arg[]){ Compiles and Display() runtime Compilation
show();}} prints show() show() exception error
29 Consider the following code and choose the
best option:
class Super{ int x; Super(){x=2;}}
class Sub extends Super { void displayX(){
System.out.print(x);} Compiles and
public static void main(String args[]){ Compilation runs without Compiles and Compiles and
new Sub().displayX();}} error any output display 2 display 0
30 class One{
int var1;
One (int x){
var1 = x;
}}
class Derived extends One{
int var2;
Derived(){
super(10);
var2=10;
}
void display(){
System.out.println("var1="+var1+" ,
var2="+var2);
}}
class Main{
public static void main(String[] args){
Derived obj = new Derived();
obj.display();
}}
consider the code above & select the proper var1=10 ,
output from the options. var2=10 0,0 compile error runtime error
31 public class MyAr {
static int i1;
public static void main(String argv[]) {
MyAr m = new MyAr();
m.amethod();
} It is not
public void amethod() { possible to
System.out.println(i1); access a
} static variable
} Compilation Garbage in side of non
What is the output of the program? 0 Error Value static method
32 What will be printed out if you attempt to
compile and run the following code ?
public class AA {
public static void main(String[] args) {
int i = 9;
switch (i) {
default:
System.out.println("default");
case 0:
System.out.println("zero");
break;
case 1:
System.out.println("one");
case 2:
System.out.println("two");
}
} Compilation default zero
} Error default default zero one two
33 Which statements, when inserted at (1), will
not result in compile-time errors?
public class ThisUsage {
int planets;
static int suns;
public void gaze() {
int i;
// (1) INSERT STATEMENT HERE
} i= this = new this.suns =
} this.planets; i = this.suns; ThisUsage(); planets;
34 Which modifier is used to control access to
critical code in multi-threaded programs? default public transient synchronized
Given:
35 package QB;

class Meal {
Meal() {
System.out.println("Meal()");
}
}
class Cheese {
Cheese() {
System.out.println("Cheese()");
}
}
class Lunch extends Meal {
Lunch() {
System.out.println("Lunch()");
}
}
class PortableLunch extends Lunch {
PortableLunch() {
System.out.println("PortableLunch()");
}
}
class Sandwich extends PortableLunch {
private Cheese c = new Cheese();

public Sandwich() {
System.out.println("Sandwich()"); Meal() Meal() Cheese()
} Meal() Cheese() Lunch() Sandwich()
} Lunch() Lunch() PortableLunc Meal()
public class MyClass7 { PortableLunc PortableLunc h() Lunch()
public static void main(String[] args) { h() Cheese() h() Sandwich() PortableLunc
new Sandwich(); Sandwich() Sandwich() Cheese() h()
36 Consider the following code and choose the
correct option:
class A{ int a; A(int a){a=4;}}
class B extends A{ B(){super(3);} void
displayA(){
System.out.print(a);}
public static void main(String args[]){ compiles and compilation Compiles and Compiles and
new B().displayA();}} display 0 error display 4 display 3
37
Given the following code what will be output?
public class Pass{
static int j=20;
public static void main(String argv[]){
int i=10;
Pass p = new Pass();
p.amethod(i);
System.out.println(i);
System.out.println(j);
}
Error:
public void amethod(int x){ amethod
x=x*2; parameter
j=j*2; does not
} match
} variable 20 and 40 10 and 40 10, and 20
38 The compiler
will
automatically The program
change the The compiler will compile
What will happen if a main() method of a private will find the The program successfully,
"testing" class tries to access a private variable to a error and will will compile but the .class
instance variable of an object using dot public not make a and run file will not
notation? variable .class file successfully run correctly
39 11. class Mud {
12. // insert code here
13. System.out.println("hi");
14. }
15. }
And the following five fragments:
public static void main(String...a) {
public static void main(String.* a) {
public static void main(String... a) {
public static void main(String[]... a) {
public static void main(String...[] a) {
How many of the code fragments, inserted
independently at line 12, compile? 0 1 2 3
40 class Order{
Order(){
System.out.println("Cat");
}
public static void main(String... Args){
Order obj = new Order();
System.out.println("Ant");
}
static{
System.out.println("Dog");
}
{
System.out.println("Man");
}}
consider the code above & select the proper Man Dog Cat Cat Ant Dog Dog Man Cat
output from the options. Ant Man Ant compile error
41 abstract class MineBase {
abstract void amethod();
static int i;
} Compilation
public class Mine extends MineBase { Error occurs
public static void main(String argv[]){ and to avoid
int[] ar=new int[5]; them we
for(i=0;i < ar.length;i++) A Sequence A Sequence need to
System.out.println(ar[i]); of 5 zero's of 5 one's will declare Mine
} will be printed be printed IndexOutOfB class as
} like 0 0 0 0 0 like 1 1 1 1 1 oundes Error abstract
42 public class Q {
public static void main(String argv[]) { Compiler
int anar[] = new int[] { 1, 2, 3 }; Error: anar is Compiler
System.out.println(anar[1]); referenced Error: size of
} before it is array must be
} initialized 2 1 defined
43 A constructor may return value including class
type true false
44 Consider the following code and choose the
correct option:
package aj; class S{ int roll =23;
private S(){} }
package aj; class T
{ public static void main(String ar[]){ Compilation Compiles and Compiles and Compiles but
System.out.print(new S().roll);}} error display 0 display 23 no output
45 public class c123 {
private c123() {
System.out.println("Hellow");
}
public static void main(String args[]) {
c123 o1 = new c123();
c213 o2 = new c213();
}
}
class c213 {
private c213() {
System.out.println("Hello123"); It is not
} possible to
} declare a
constructor Compilation Runs without
What is the output? Hellow as private Error any output
46 class MyClass1
{
private int area(int side)
{
return(side * side);
}
public static void main(String args[ ])
{
MyClass1 MC = new MyClass1( );
int area = MC.area(50);
System.out.println(area);
}
} Compilation Runtime
What would be the output? error Exception 2500 50
47

It is not
possible to
declare a
public class MyAr { static variable
public static void main(String argv[]) { in side of non
MyAr m = new MyAr(); static method
m.amethod(); or instance
} method.
public void amethod() { Because
static int i1; Compile time Static
System.out.println(i1); error variables are
} because i Compilation class level
} has not been and output of dependencie
What is the Output of the Program? 0 initialized null s.
48 public class MyAr {
public static void main(String argv[]) {
MyAr m = new MyAr();
m.amethod();
} Unresolved
public void amethod() { compilation
final int i1; problem: The
System.out.println(i1); local variable
} i1 may not Compilation
} have been and output of None of the
What is the Output of the Program? 0 initialized null given options
49 public class c1 {
private c1()
{
System.out.println("Hello");
}
public static void main(String args[])
{
c1 o1=new c1(); It is not Can't create
} possible to object
} declare a because
constructor Compilation constructor is
What is the output? Hello private Error private
50 Which modifier indicates that the variable
might be modified asynchronously, so that all
threads will get the correct value of the
variable. synchronized volatile transient default
51
class A {
int i, j;

A(int a, int b) {
i = a;
j = b;
}
void show() {
System.out.println("i and j: " + i + " " + j);
}
}
class B extends A {
int k;

B(int a, int b, int c) {


super(a, b);
k = c;
}
void show(String msg) {
System.out.println(msg + k);
}
}
class Override {
public static void main(String args[]) {
B subOb = new B(3, 5, 7);
subOb.show("This is k: "); // this calls
show() in B
subOb.show(); // this calls show() in A
} This is j: 5 i This is i: 3 j This is i: 7 j This is k: 7 i
} What would be the ouput? and k: 3 7 and k: 5 7 and k: 3 5 and j: 3 7
52 Consider the following code and choose the
correct option:
class X { int x; X(int x){x=2;}}
class Y extends X{ Y(){} void displayX(){
System.out.print(x);} Compiles and
public static void main(String args[]){ Compiles and runs without Compiles and Compilation
new Y().displayX();}} display 2 any output display 0 error
53 class Order{
Order(){
System.out.println("Cat");
}
public static void main(String... Args){
Order obj = new Order();
System.out.println("Ant");
}
static{
System.out.println("Dog");
}}
consider the code above & select the proper
output from the options. Cat Ant Dog Dog Cat Ant Ant Cat Dog none
54 What will be the result when you attempt to
compile this program?
public class Rand{
public static void main(String argv[]){
int iRand; A compile
iRand = Math.random(); Compile time A random A random time error as
System.out.println(iRand); error referring number number random being
} to a cast between 1 between 0 an undefined
} problem and 10 and 1 method
55 Choose the meta annotations. (Choose
THREE) Target Retention Depricated Documented
56 If no retention policy is specified for an
annotation, then the default policy of
__________ is used. method class source runtime
57 Select the variable which are in
java.lang.annotation.RetentionPolicy class. CONSTRUC
(Choose THREE) SOURCE CLASS RUNTIME TOR
58 Compile time
Information and
Select the Uses of annotations. (Choose For the Information deploytime Runtime
THREE) Compiler for the JVM processing processing
59
All annotation types should maually extend
the Annotation interface. State TRUE/FALSE true false
60 all the listed
Custom annotations can be created using @interface @inherit @include options
61 Given:
10. interface A { void x(); }
11. class B implements A {
public void x() { }
public void y() { } }
12. class C extends B {
public void x() {} }
And:
20. java.util.List<a> list = new
java.util.ArrayList</a>();
21. list.add(new B());
22. list.add(new C());
23. for (A a:list) {
24. a.x(); Compilation Compilation
25. a.y();; fails because The code An exception fails because
26. } of an error in runs with no is thrown at of an error in
What is the result? line 25 output. runtime line 21
62 Given:
public static Collection get() {
Collection sorted = new LinkedList();
sorted.add("B"); sorted.add("C");
sorted.add("A");
return sorted;
}
public static void main(String[] args) {
for (Object obj: get()) {
System.out.print(obj + ", ");
} An exception
} Compilation is thrown at
What is the result? A, B, C, B, C, A, fails. runtime.
63 Which statement is true about the following
program?
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class WhatISThis {
public static void main(String[] na){
List<StringBuilder> list=new
ArrayList<StringBuilder>();
list.add(new StringBuilder("B"));
list.add(new StringBuilder("A"));
list.add(new StringBuilder("C"));
Collections.sort(list,Collections.reverseOrder() The program The program The program
); will compile will compile will compile
System.out.println(list.subList(1,2)); and print the and print the and throw a The program
} following following runtime will not
} output: [B] output: [B,A] exception compile
64 Consider the following code and choose the
correct option:
public static void before() {
Set set = new TreeSet();
set.add("2");
set.add(3);
set.add("1"); The before()
Iterator it = set.iterator(); method will
while (it.hasNext()) The before() The before() throw an The before()
System.out.print(it.next() + " "); method will method will exception at method will
} print 1 2 print 1 2 3 runtime not compile
65 import java.util.StringTokenizer;
class ST{
public static void main(String[] args){
String input = "Today is$Holiday";
StringTokenizer st = new
StringTokenizer(input,"$");
while(st.hasMoreTokens()){
System.out.println(st.nextElement()); Today is Today is none of the
}} Holiday Holiday Both listed options
66 Given:
public static Iterator reverse(List list) {
Collections.reverse(list);
return list.iterator();
}
public static void main(String[] args) {
List list = new ArrayList();
list.add("1"); list.add("2"); list.add("3");
for (Object obj: reverse(list))
System.out.print(obj + ", "); The code
} Compilation runs with no
What is the result? 3, 2, 1, 1, 2, 3, fails. output.
67
Which collection class allows you to grow or
shrink its size and provides indexed access to
its elements, but its methods are not java.util.Hash java.util.Linke java.util.Array
synchronized? Set dHashSet java.util.List List
68
int indexOf(Object o) - What does this method none of the
return if the element is not found in the List? null -1 0 listed options
69 What is the result of attempting to compile
and run the following code?
import java.util.Vector; import
java.util.LinkedList; public class Test1{ public
static void main(String[] args) { Integer int1 =
new Integer(10); Vector vec1 = new Vector();
LinkedList list = new LinkedList();
vec1.add(int1); list.add(int1);
if(vec1.equals(list))
System.out.println("equal"); else
System.out.println("not equal"); } } 1. The code
will fail to compile. 2. Runtime error due to
incompatible object comparison 3. Will run
and print "equal". 4. Will run and print "not
equal". 1 2 3 4
70 Consider the following code and choose the
correct option:
class Test{
public static void main(String args[]){
Integer arr[]={3,4,3,2};
Set<Integer> s=new
TreeSet<Integer>(Arrays.asList(arr));
s.add(1); Compiles but
for(Integer ele :s){ Compilation exception at
System.out.println(ele); } }} error prints 3,4,2,1, prints 1,2,3,4 runtime
71

Inorder to remove one element from the given


Treeset, place the appropriate line of code
public class Main {
public static void main(String[] args) {
TreeSet<Integer> tSet = new
TreeSet<Integer>();
System.out.println("Size of TreeSet : " +
tSet.size());
tSet.add(new Integer("1"));
tSet.add(new Integer("2"));
tSet.add(new Integer("3"));
System.out.println(tSet.size());
// remove the one element from the Treeset
System.out.println("Size of TreeSet after
removal : " + tSet.size()); tSet.clear(ne tSetdelete(ne tSet.remove( tSet.drop(ne
} w w new w
} Integer("1")); Integer("1")); Integer("1")); Integer("1"));
72

Consider the code below & select the correct


ouput from the options:
public class Test{
public static void main(String[] args) {
String
[]colors={"orange","blue","red","green","ivory"};
Arrays.sort(colors);
int s1=Arrays.binarySearch(colors, "ivory");
int s2=Arrays.binarySearch(colors, "silver");
System.out.println(s1+" "+s2); }} 2 -4 3 -5 2 -6 3 -4
73 Consider the following code and choose the
correct output:
class Test{
public static void main(String args[]){
TreeMap<Integer, String> hm=new
TreeMap<Integer, String>();
hm.put(2,"Two");
hm.put(4,"Four");
hm.put(1,"One");
hm.put(6,"Six");
hm.put(7,"Seven");
SortedMap<Integer, String>
sm=hm.subMap(2,7);
SortedMap<Integer,String> {2=Two,
sm2=sm.tailMap(4); 4=Four, {4=Four, {2=Two,
System.out.print(sm2); 6=Six, 6=Six, {4=Four, 4=Four,
}} 7=Seven} 7=Seven} 6=Six} 6=Six}
74 next() method of Scanner class will return
_________ Integer Long int String
75
Given:
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class MainClass {

public static void main(String[] a) {


String elements[] = { "A", "B", "C", "D", "E" };
Set set = new
HashSet(Arrays.asList(elements));

elements = new String[] { "A", "B", "C", "D"


};
Set set2 = new
HashSet(Arrays.asList(elements));

System.out.println(set.equals(set2));
} Compile time Runtime
} What is the result of given code? true false error Exception
76 A)Property files help to decrease coupling
B) DateFormat class allows you to format
dates and times with customized styles.
C) Calendar class allows to perform date
calculation and conversion of dates and times
between timezones. A and B is A and D is A and C is B and D is
D) Vector class is not synchronized TRUE TRUE TRUE TRUE
77 Which interface does java.util.Hashtable Java.util.Tabl Java.util.Coll
implement? Java.util.Map Java.util.List e ection
78 Object get(Object key) - What does this
method return if the key is not found in the none of the
Map? 0 -1 null listed options
79 Consider the following code and choose the
correct option:
class Test{
public static void main(String args[]){
TreeSet<Integer> ts=new
TreeSet<Integer>();
ts.add(1);
ts.add(8);
ts.add(6);
ts.add(4);
SortedSet<Integer> ss=ts.subSet(2, 10);
ss.add(9);
System.out.println(ts);
System.out.println(ss); [1,4,6,8] [1,8,6,4] [1,4,6,8,9] [1,4,6,8,9]
}} [4,6,8,9] [8,6,4,9] [4,6,8,9] [4,6,8]
80 A) Iterator does not allow to insert elements
during traversal
B) Iterator allows bidirectional navigation.
C) ListIterator allows insertion of elements
during traversal
D) ListIterator does not support bidirectional A and B is A and D is A and C is B and D is
navigation TRUE TRUE TRUE TRUE
81 static void sort(List list) method is part of Collection Collections ArrayList
________ interface class Vector class class
82 static int binarySearch(List list, Object key) is ArrayList Collection Collections
a method of __________ Vector class class interface class
83 Which collection class allows you to access
its elements by associating a key with an
element's value, and provides java.util.Sorte java.util.Tree java.util.Tree java.util.Hash
synchronization? dMap Map Set table
84
Consider the following code and select the
correct output:
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
public class Lists {
public static void main(String[] args) {
List<String> list=new ArrayList<String>();
list.add("1");
list.add("2");
list.add(1, "3");
List<String> list2=new LinkedList<String>(list);
list.addAll(list2);
list2 =list.subList(2,5);
list2.clear();
System.out.println(list);
}
} [1,3,2] [1,3,3,2] [1,3,2,1,3,2] [3,1,2]
85 Given:
import java.util.*;

public class LetterASort{


public static void main(String[] args) {
ArrayList<String> strings = new
ArrayList<String>();
strings.add("aAaA");
strings.add("AaA");
strings.add("aAa");
strings.add("AAaa");
Collections.sort(strings);
for (String s : strings) { System.out.print(s + "
"); }
}
} Compilation aAaA aAa AAaa AaA AaA AAaa
What is the result? fails. AAaa AaA aAa aAaA aAaA aAa
86 A) It is a good practice to store heterogenous
data in a TreeSet.
B) HashSet has default initial capacity (16)
and loadfactor(0.75)
C)HashSet does not maintain order of
Insertion A and B is A and D is A and C is B and C is
D)TreeSet maintains order of Inserstion TRUE TRUE TRUE TRUE
87

TreeSet<String> s = new TreeSet<String>();


TreeSet<String> subs = new
TreeSet<String>();
s.add("a"); s.add("b"); s.add("c"); s.add("d");
s.add("e");

subs = (TreeSet)s.subSet("b", true, "d", true);


s.add("g");
s.pollFirst();
s.pollFirst();
s.add("c2"); The size of s The size of s The size of The size of s
System.out.println(s.size() +" "+ subs.size()); is 4 is 5 subs is 3 is 7
88 Consider the following code was executed on
June 01, 1983. What will be the output?
class Test{
public static void main(String args[]){
Date date=new Date();
SimpleDateFormat sd;
sd=new SimplpeDateFormat("E MMM dd
yyyy"); Wed Jun 01 244 JUN 01 PST JUN 01 GMT JUN 01
System.out.print(sd.format(date));}} 1983 1983 1983 1983
89 Given:
public class Venus {
public static void main(String[] args) {
int [] x = {1,2,3};
int y[] = {4,5,6};
new Venus().go(x,y);
}
void go(int[]... z) {
for(int[] a : z)
System.out.print(a[0]);
}
} What is the result? 123 12 14 1
90
You wish to store a small amount of data and
make it available for rapid access. You do not
have a need for the data to be sorted,
uniqueness is not an issue and the data will
remain fairly static Which data structure might
be most suitable for this requirement?

1) TreeSet
2) HashMap
3) LinkedList
4) an array 1 2 3 4
91 What will be the output of following code?
class Test{
public static void main(String args[]){
TreeSet<Integer> ts=new
TreeSet<Integer>();
ts.add(2);
ts.add(3);
ts.add(7);
ts.add(5);
SortedSet<Integer> ss=ts.subSet(1,7);
ss.add(4);
ss.add(6);
System.out.print(ss);}} [2,3,7,5] [2,3,7,5,4,6] [2,3,4,5,6,7] [2,3,4,5,6]
92
Consider the following code and choose the
correct option:
class Data{ Integer data; Data(Integer
d){data=d;}
public boolean equals(Object o){return true;}
public int hasCode(){return 1;}}
class Test{
public static void main(String ar[]){
Set<Data> s=new HashSet<Data>();
s.add(new Data(4));
s.add(new Data(2));
s.add(new Data(4));
s.add(new Data(1)); Compiles but
s.add(new Data(2)); compilation error at run
System.out.print(s.size());}} 3 5 error time
93 Consider the code below & select the correct
ouput from the options:
public class Test{
public static void main(String[] args) {
String num="";
z: for(int x=0;x<3;x++)
for(int y=0;y<2;y++){
if(x==1) break;
if(x==2 && y==1) break z;
num=num+x+y; 0 0 0 1 2 0 2 Compilation
}System.out.println(num);}} 0001 000120 1 error
94 Given:
public class Test {
public enum Dogs {collie, harrier};
public static void main(String [] args) {
Dogs myDog = Dogs.collie;
switch (myDog) {
case collie:
System.out.print("collie ");
case harrier:
System.out.print("harrier ");
}
}
} Compilation
What is the result? collie harrier fails. collie harrier
95 Consider the following code and choose the
correct output:
class Test{
public static void main(String args[]){
boolean flag=true;
if(flag=false){
System.out.print("TRUE");}else{ compilation
System.out.print("FALSE");}}} true false error Compiles
96 Cosider the following code and choose the
correct option:
class Test{
public static void main(String args[]){
System.out.println(Integer.parseInt("21474836 NumberForm
48", 10)); Compilation atException Compiles but
}} error 2.15E+09 at run time no output
97
Given:
public class Test {
public enum Dogs {collie, harrier, shepherd};
public static void main(String [] args) {
Dogs myDog = Dogs.shepherd;
switch (myDog) {
case collie:
System.out.print("collie ");
case default:
System.out.print("retriever ");
case harrier:
System.out.print("harrier ");
}
}
} Compilation
What is the result? harrier shepherd retriever fails.
98 Given:
static void myFunc()
{
int i, s = 0;
for (int j = 0; j < 7; j++) {
i = 0;
do {
i++;
s++;
} while (i < j);
}
System.out.println(s);
}
} What would be the result 20 21 22 23
99
What is the range of the random number r
generated by the code below?
int r = (int)(Math.floor(Math.random() * 8)) + 2; 2 <= r <= 9 3 <= r <= 10 2<= r <= 10 3 <= r <= 9
100 class Test{
public static void main(String[] args) {
int x=-1,y=-1;
if(++x=++y)
System.out.println("R.T. Ponting");
else
System.out.println("C.H. Gayle");
}
}
consider the code above & select the proper none of the
output from the options. R.T.Ponting C.H.Gayle Compile error listed options
101 Given:
public class Breaker2 {
static String o = "";
public static void main(String[] args) {
z:
for(int x = 2; x < 7; x++) {
if(x==3) continue;
if(x==5) break z;
o = o + x;
}
System.out.println(o);
}
}
What is the result? 2 24 234 246
102 Consider the following code and choose the
correct output:
class Test{
public static void main(String args[]){
int a=5;
if(a=3){
System.out.print("Three");}else{ Compilation Compiles but
System.out.print("Five");}}} error Three Five no output
103 Given:
public class Batman {
int squares = 81;
public static void main(String[] args) {
new Batman().go();
}
void go() {
incr(++squares);
System.out.println(squares);
}
void incr(int squares) { squares += 10; }
}
What is the result? 81 82 91 92
104 public void foo( boolean a, boolean b)
{
if( a )
{
System.out.println("A"); /* Line 5 */
}
else if(a && b) /* Line 7 */
{
System.out.println( "A && B");
}
else /* Line 11 */
{
if ( !b )
{
System.out.println( "notB") ;
}
else
{
System.out.println( "ELSE" ) ;
} If a is true If a is true If a is false If a is false
} and b is false and b is true and b is false and b is true
} then the then the then the then the
output is output is "A output is output is
What would be the result? "notB" && B" "ELSE" "ELSE"
105 What is the value of ’n’ after executing the
following code?
int n = 10;
int p = n + 5;
int q = p - 10;
int r = 2 * (p - q);
switch(n)
{
case p: n = n + 1;
case q: n = n + 2;
case r: n = n + 3;
default: n = n + 4; Compilation
} 14 28 Error 10
106 public class While
{
public void loop()
{
int x= 0;
while ( 1 ) /* Line 6 */
{
System.out.print("x plus one is " + (x +
1)); /* Line 8 */
}
} There are There are
} There is a syntax errors syntax errors There is a
syntax error on lines 1 on lines 1, 6, syntax error
Which statement is true? on line 1 and 6 and 8 on line 6
107 Which of the following loop bodies DOES
compute the product from 1 to 10 like (1 * 2 *
3*4*5*
6 * 7 * 8 * 9 * 10)?
int s = 1;
for (int i = 1; i <= 10; i++)
{
<What to put here?>
} s += i * i; s++; s = s + s * i; s *= i;
108 Character
String is a Double has a has a
Which of the following statements are true wrapper compareTo() intValue() Byte extends
regarding wrapper classes? (Choose TWO) class method method Number
109
Given:
class Atom {
Atom() { System.out.print("atom "); }
}
class Rock extends Atom {
Rock(String type) { System.out.print(type); }
}
public class Mountain extends Rock {
Mountain() {
super("granite ");
new Rock("granite ");
}
public static void main(String[] a) { new
Mountain(); }
} Compilation granite atom granite atom granite
What is the result? fails. granite granite atom granite
110 What are the thing to be placed to complete
the code?
class Wrap {
public static void main(String args[]) {

_______________ iOb = ___________


Integer(100);

int i = iOb.intValue();

System.out.println(i + " " + iOb); // displays


100 100
}
} int, int Integer, new Integer, int int, Integer
111 public class SwitchTest
{
public static void main(String[] args)
{
System.out.println("value =" +
switchIt(4));
}
public static int switchIt(int x)
{
int j = 1;
switch (x)
{
case 1: j++;
case 2: j++;
case 3: j++;
case 4: j++;
case 5: j++;
default: j++;
}
return j + x;
}
}
What will be the output of the program? value = 8 value = 2 value = 4 value = 6
112 Given:
public class Barn {
public static void main(String[] args) {
new Barn().go("hi", 1);
new Barn().go("hi", "world", 2);
}
public void go(String... y, int x) {
System.out.print(y[y.length - 1] + " ");
}
} Compilation
What is the result? hi hi hi world world world fails.
113 Consider the following code and choose the
correct option:
class Test{
public static void main(String args[]){ int
x=034;
int y=12;
int ans=x+y; Compiles but
System.out.println(ans); compilation error at run
}} 40 46 error time
114
11. double input = 314159.26;
12. NumberFormat nf =
NumberFormat.getInstance(Locale.ITALIAN);
13. String b;
14. //insert code here
b=
Which code, inserted at line 14, sets the value b = nf.parse( b = nf.format( b = nf.equals( nf.parseObje
of b to 314.159,26? input ); input ); input ); ct( input );
115 Consider the following code and choose the
correct option:
class Test{
public static void main(String ar[]){
TreeMap<Integer,String> tree = new
TreeMap<Integer,String>();
tree.put(1, "one");
tree.put(2, "two");
tree.put(3, "three");
tree.put(4,"Four");
System.out.println(tree.higherKey(2));
System.out.println(tree.ceilingKey(2));
System.out.println(tree.floorKey(1));
System.out.println(tree.lowerKey(1));
}} 3 2 1 null 3211 2211 4211
116 Consider the following code and choose the
correct option:
class Test{
public static void main(String args[]){ Compiles but
Long data=23; Compilation error at run None of the
System.out.println(data); }} 23 error time listed options
117 class AutoBox {
public static void main(String args[]) {

int i = 10;
Integer iOb = 100;
i = iOb;
System.out.println(i + " " + iOb);
} No,
} whether this code work properly, if so what Compilation No, Runtime Yes, 100,
would be the result? error error Yes, 10, 100 100
118 Consider the following code and choose the
correct option:
class Test{
public static void main(String args[]){
Long l=0l; Compilation
System.out.println(l.equals(0));}} error true false 1
119 int I = 0;
outer:
while (true)
{
I++;
inner:
for (int j = 0; j < 10; j++)
{
I += j;
if (j == 3)
continue inner;
break outer;
}
continue outer;
}
System.out.println(I);

What will be thr result? 3 2 4 1


120
what will be the result of attempting to compile
and run the following class? The code will
Public class IFTest{ fail to compile
public static void main(String[] args){ because the
int i=10; compiler will
if(i==10) The code will not be able to The code will The code will
if(i<10) fail to compile determine compile compile
System.out.println("a"); because the which if correctly and correctly and
else syntax of the statement the display the display the
System.out.println("b"); if statement else clause letter a,when letter b,when
}} is incorrect belongs to run run
121 What is the output of the following code :
class try1{
public static void main(String[] args) {
System.out.println("good");
while(false){
System.out.println("morning");
}
} good morning
} good morning …. compiler error runtime error
122 Consider the following code and choose the
correct output:
class Test{
public static void main(String args[]){
int num=3; switch(num){
case 1: case 3: case 4: {
System.out.println("bat man"); }
case 2: case 5: {
System.out.println("spider man"); }break; } Compilation bat man
}} bat man error spider man spider man
123 Given:
int n = 10;
switch(n)
{
case 10: n = n + 1;
case 15: n = n + 2;
case 20: n = n + 3;
case 25: n = n + 4;
case 30: n = n + 5;
}
System.out.println(n);
What is the value of ’n’ after executing the Compilation
following code? 23 32 25 Error
124 What will be the output of following code?

TreeSet map = new TreeSet();


map.add("one");
map.add("two");
map.add("three");
map.add("four");
map.add("one");
Iterator it = map.iterator();
while (it.hasNext() )
{
System.out.print( it.next() + " " ); one two three four three two four one one two three
} four one three two four one
125 public class Test {
public static void main(String [] args) {
int x = 5;
boolean b1 = true;
boolean b2 = false;

if ((x == 4) && !b2 )


System.out.print("1 ");
System.out.print("2 ");
if ((b2 = true) && b1 )
System.out.print("3 ");
}
}
What is the result? 2 323 123
126 HashTable is ArrayList is a LinkedList is Stack is a
a sub class of sub class of a subclass of subclass of
Which of these statements are true? Dictionary Vector ArrayList Vector
127 Given:
import java.util.*;
public class Explorer3 {
public static void main(String[] args) {
TreeSet<Integer> s = new
TreeSet<Integer>();
TreeSet<Integer> subs = new
TreeSet<Integer>();
for(int i = 606; i < 613; i++)
if(i%2 == 0) s.add(i);
subs = (TreeSet)s.subSet(608, true, 611,
true);
subs.add(629);
System.out.println(s + " " + subs); [608, 610,
} [608, 610, An exception 612, 629]
} Compilation 612, 629] is thrown at [608, 610,
What is the result? fails. [608, 610] runtime. 629]
128 What is the output :
class try1{
public static void main(String[] args) {
int x=1;
if(x--)
System.out.println("good");
else
System.out.println("bad");
}
} good bad compile error run time error
129 Consider the following code and choose the
correct output:
class Test{
public static void main(String args[]){
int num='b'; switch(num){
default :{
System.out.print("default");}
case 100 : case 'b' : case 'c' : {
System.out.println("brownie"); break;}
case 200: case 'e': { default compilation
System.out.println("pastry"); }break; } }} brownie brownie error default
130 Given:
int a = 5;
int b = 5;
int c = 5;
if (a > 3)
if (b > 4)
if (c > 5)
c += 1;
else
c += 2;
else
c += 3;
c += 4;
What is the value of variable c after executing
the following code? 3 5 7 11
131
Given:
Float pi = new Float(3.14f);
if (pi > 3) {
System.out.print("pi is bigger than 3. ");
}
else {
System.out.print("pi is not bigger than 3. ");
}
finally {
System.out.println("Have a nice day."); An exception pi is bigger
} Compilation pi is bigger occurs at than 3. Have
What is the result? fails. than 3. runtime. a nice day.
132 Given:
public void go() {
String o = "";
z:
for(int x = 0; x < 3; x++) {
for(int y = 0; y < 2; y++) {
if(x==1) break;
if(x==2 && y==1) break z;
o = o + x + y;
}
}
System.out.println(o);
}
What is the result when the go() method is 0001202
invoked? 00 0001 000120 1
133 Examine the following code:

int count = 1;
while ( ___________ )
{
System.out.print( count + " " );
count = count + 1;
}
System.out.println( );

What condition should be used so that the


code prints:

12345678 count < 9 count+1 <= 8 count < 8 count != 8


134 What will be the output of the program?

public class Switch2


{
final static short x = 2;
public static int y = 0;
public static void main(String [] args)
{
for (int z=0; z < 3; z++)
{
switch (z)
{
case y: System.out.print("0 "); /*
Line 11 */
case x-1: System.out.print("1 "); /*
Line 12 */
case x: System.out.print("2 "); /*
Line 13 */
}
} Compilation
} Compilation fails at line
} 012 012122 fails at line 11 12.
135 Given:
int x = 0;
int y = 10;
do {
y--;
++x;
} while (x < 5);
System.out.print(x + "," + y);
What is the result? 5,6 5,5 6,5 6,6
136 What is the output :
class Test{
public static void main(String[] args) {
int a=5,b=10,c=1;
if(a>c){
System.out.println("success");
}
else{
break;
}
} none of the
} success runtime error compiler error listed options
137 Consider the following code and choose the
correct output:
public class Test{
public static void main(String[] args) {
int x = 0;
int y = 10;
do {
y--;
++x;
} while (x < 5);
System.out.print(x + "," + y);
}
} 5,6 5,5 6,5 6,6
138 Consider the following code and choose the
correct option:
class Test{
public static void main(String args[]){
int l=7; Compiles but
Long L = (Long)l; Compilation error at run None of the
System.out.println(L); }} 7 error time listed options
139 Given:
double height = 5.5;
if(height-- >= 5.0)
System.out.print("tall ");
if(--height >= 4.0)
System.out.print("average ");
if(height-- >= 3.0)
System.out.print("short ");
else
System.out.print("very short ");
}
What would be the Result? tall tall short short very short
140 Consider the following code and choose the
correct option:
class Test{
public static void main(String args[]){
String hexa = "0XFF"; Compiles but
int number = Integer.decode(hexa); Compilation error at run
System.out.println(number); }} error 1515 255 time
141 Consider the following code and choose the
correct option:
int i = l, j = -1;
switch (i)
{
case 0, 1: j = 1;
case 2: j = 2;
default: j = 0;
} Compilation
System.out.println("j = " + j); j = -1 j=0 j=1 fails
142 Person[] p = Person p[][] =
Which of the following statements about new new
arrays is syntactically wrong? Person[5]; Person p[5]; Person[] p []; Person[2][];
143

What will be the output of following code?

import java.util.*;
class I
{
public static void main (String[] args)
{
Object i = new ArrayList().iterator();
System.out.print((i instanceof List)+",");
System.out.print((i instanceof
Iterator)+",");
System.out.print(i instanceof ListIterator);
} Prints: false, Prints: false, Prints: false, Prints: false,
} false, false false, true true, false true, true
144
Given:
public static void test(String str) {
int check = 4;
if (check = str.length()) {
System.out.print(str.charAt(check -= 1) +", ");
} else {
System.out.print(str.charAt(0) + ", ");
}
}
and the invocation:
test("four");
test("tee"); An exception
test("to"); Compilation is thrown at
What is the result? r, t, t, r, e, o, fails. runtime.
145 What will be the output of the program?
int x = 3;
int y = 1;
if (x = y) /* Line 3 */
{ The code
System.out.println("x =" + x); Compilation runs with no
} x=1 x=3 fails. output.
146
import java.util.SortedSet;
import java.util.TreeSet;

public class Main {

public static void main(String[] args) {


TreeSet<String> tSet = new
TreeSet<String>();
tSet.add("1");
tSet.add("2");
tSet.add("3");
tSet.add("4");
tSet.add("5");
SortedSet sortedSet =_____________("3");
System.out.println("Head Set Contains : " +
sortedSet);
}
} What is the missing method in the code to
get the head set of the tree set? tSet.headSet tset.headset headSet HeadSet
147 Consider the following code and choose the
correct output:
class Test{
public static void main(String args[]){
int num=3; switch(num){
default :{
System.out.print("default");}
case 1: case 3: case 4: {
System.out.println("apple"); break;}
case 2: case 5: {
System.out.println("black berry"); }break; } compilation
}} apple default apple error default
148 Consider the following code and choose the
correct option:
class Test{
public static void main(String args[]){
Long L = null; long l = L;
System.out.println(L); Compiles but
System.out.println(l); Compilation error at run
}} null 0 error time 0 null
149 What does the following code fragment write
to the monitor?

int sum = 21;


if ( sum != 20 )
System.out.print("You win ");
else
System.out.print("You lose ");

System.out.println("the prize.");
You win the You lose the
What does the code fragment prints? prize prize. You win You lose
150 Changes
made in the
Set view
returned by The Map
The return keySet() will interface
type of the be reflected extends the All keys in a
Which statements are true about maps? values() in the original Collection map are
(Choose TWO) method is set map interface unique
151 Which collection implementation is suitable for
maintaining an ordered sequence of
objects,when objects are frequently inserted in
and removed from the middle of the
sequence? TreeMap HashSet Vector LinkedList
152 OutputStrea To write
m is the characters to
abstract an
superclass of Subclasses outputstream, To write an
all classes of the class you have to object to a
that Reader are make use of file, you use
represent an used to read the class the class
outputstream character CharacterOut ObjectFileWri
Choose TWO correct options: of bytes. streams. putStream. ter
153 What is the output :
class One{
public static void main(String[] args) {
int a=100;
if(a>10)
System.out.println("M.S.Dhoni");
else if(a>20)
System.out.println("Sachin");
else if(a>30) M.S.Dhoni
System.out.println("Virat Kohli");} Sachin Virat
} M.S.Dhoni Kohli Virat Kohli all of these
154 A continue If a variable
statement of type int
doesn’t overflows
transfer during the
control to the An overflow execution of
test error can only A loop may a loop, it will
Which of the following statements is TRUE statement of occur in a have multiple cause an
regarding a Java loop? the for loop loop exit points exception
155 switch(x)
{
default:
System.out.println("Hello");
}
Which of the following are acceptable types
for x?
1.byte
2.long
3.char
4.float
5.Short
6.Long 1 ,3 and 5 2 and 4 3 and 5 4 and 6
156 When an
exception When no
occurs then a exception
part of try occurs then
block will complete try
Used to execute one block and
release the appropriate finally block
resources catch block will execute
which are Writing finally and finally but no catch
Which are true with respect to finally block? obtained in block is block will be block will
(Choose THREE) try block. optional. executed. execute.
157 What will happen when you attempt to
compile and run the following code?
public class Bground extends Thread{
public static void main(String argv[]){
Bground b = new Bground();
b.run();
} A compile A run time
public void start(){ time error error
for (int i = 0; i <10; i++){ indicating indicating Clean
System.out.println("Value of i = that no run that no run compile and
" + i); method is method is at run time Clean
} defined for defined for the values 0 compile but
} the Thread the Thread to 9 are no output at
} class class printed out runtime
158 Given:
public void testIfA() {
if (testIfB("True")) {
System.out.println("True");
} else {
System.out.println("Not true");
}
}
public Boolean testIfB(String str) {
return Boolean.valueOf(str);
} An exception
What is the result when method testIfA is is thrown at
invoked? true Not true runtime. none
159 A thread will
Both wait() resume
and notify() The wait() execution as The notify()
must be method is soon as its method is
called from a overloaded to sleep overloaded to
Which of the following statements are true? synchronized accept a duration accept a
(Choose TWO) context. duration expires. duration
160 public class MyProgram
{
public static void throwit()
{
throw new RuntimeException();
}
public static void main(String args[])
{
try
{
System.out.println("Hello world "); The program
throwit(); will print
System.out.println("Done with try block Hello world,
"); then will print The program The program
} that a will print will print
finally RuntimeExce Hello world, Hello world,
{ ption has then will print then will print
System.out.println("Finally executing occurred, that a Finally
"); then will print RuntimeExce executing,
} Done with try ption has then will print
} block, and occurred, and that a
} The program then will print then will print RuntimeExce
which answer most closely indicates the will not Finally Finally ption has
behavior of the program? compile. executing. executing. occurred.
161 If a method is capable of causing an
exception that it does not handle, it must
specify this behavior using throws so that
callers of the method can guard themselves
against such Exception false true
162
A) Checked Exception must be explicity
caught or propagated to the calling method
B) If runtime system can not find an
appropriate method to handle the exception,
then the runtime system terminates and uses Only A is Only B is Bothe A and Both A and B
the default exception handler. TRUE TRUE B is TRUE is FALSE
163 public class RTExcept
{
public static void throwit ()
{
System.out.print("throwit ");
throw new RuntimeException();
}
public static void main(String [] args)
{
try
{
System.out.print("hello ");
throwit();
}
catch (Exception re )
{
System.out.print("caught ");
}
finally
{
System.out.print("finally ");
} hello throwit
System.out.println("after "); hello throwit RuntimeExce
} caught finally hello throwit ption caught Compilation
} after caught after fails
164 class s implements Runnable
{
int x, y;
public void run()
{
for(int i = 0; i < 1000; i++)
synchronized(this)
{
x = 12;
y = 12;
}
System.out.print(x + " " + y + " ");
}
public static void main(String args[])
{
s run = new s();
Thread t1 = new Thread(run);
Thread t2 = new Thread(run);
t1.start();
t2.start(); Cannot
} Compilation determine prints 12 12
} What is the output? DeadLock Error output. 12 12
165
What is wrong with the following code?

Class MyException extends Exception{}


public class Test{
public void foo() {
try {
bar(); Since the
} finally { method foo()
baz(); does not
} catch(MyException e) {} catch the
} exception
public void bar() throws MyException { generated by
throw new MyException(); the method A try block
} baz(),it must cannot be
public void baz() throws RuntimeException { declare the followed by
throw new RuntimeException(); RuntimeExce both a catch An empty A catch block
} ption in a and a finally catch block is cannot follow
} throws clause block not allowed a finally block
166 Consider the following code and choose the
correct option:
class Test{
static void test() throws RuntimeException {
try { System.out.print("test ");
throw new RuntimeException();
} catch (Exception ex) {
System.out.print("exception "); }
} public static void main(String[] args) {
try { test(); } catch (RuntimeException ex) { test test
System.out.print("runtime "); } test runtime exception exception
System.out.print("end"); } } test end end runtime end end
167
A method
declaring that
it throws a
If an An overriding certain
exception is method must exception
not caught in declare that it The main() class may
a method,the throws the method of a throw
method will same program can instances of
terminate and exception declare that it any subclass
normal classes as throws of that
execution will the method it checked exception
Choose TWO correct options: resume overrides exception class
168 Which four can be thrown using the throw
statement?

1.Error
2.Event
3.Object
4.Throwable
5.Exception
6.RuntimeException 1, 2, 3 and 4 2, 3, 4 and 5 1, 4, 5 and 6 2, 4, 5 and 6
169 class X implements Runnable
{
public static void main(String args[])
{
/* Missing code? */
} X run = new
public void run() {} Thread t = X(); Thread t Thread t =
} Thread t = new = new new
Which of the following line of code is suitable new Thread(X); Thread(run); Thread();
to start a thread ? Thread(X); t.start(); t.start(); x.run();
170
Given:
class X { public void foo() {
System.out.print("X "); } }

public class SubB extends X {


public void foo() throws RuntimeException {
super.foo();
if (true) throw new RuntimeException();
System.out.print("B ");
}
public static void main(String[] args) { X, followed
new SubB().foo(); No output, by an
} X, followed and an Exception,
} by an Exception is followed by
What is the result? Exception. thrown. B. none
171
What will the output of following code?

try
{
int x = 0;
int y = 5 / x;
}
catch (Exception e)
{
System.out.println("Exception");
}
catch (ArithmeticException ae)
{
System.out.println(" Arithmetic Exception");
} compilation ArithmeticExc
System.out.println("finished"); finished Exception fails eption
172 Which of the following methods are static? start() join() yield() sleep()
173 static
methods can static
static be called methods do
methods are using an not have
difficult to object static direct access
maintain, reference to methods are to non-static
because you an object of always methods
can not the class in public, which are
change their which this because they defined
Which of the following statements regarding implementati method is are defined at inside the
static methods are correct? (2 answers) on. defined. class-level. same class.
174 Consider the following code and choose the
correct option:
class Test{
static void display(){
throw new RuntimeException();
} public static void main(String args[]){
try{display();
}catch(Exception e){ throw new
NullPointerException();}
finally{try{ display(); exit
}catch(NullPointerException e){ RuntimeExce
System.out.println("caught");} ption thrown Compilation
finally{ System.out.println("exit");}}}} caught exit exit at run time fails
175 class Test{
public static void main(String[] args){
try{
Integer.parseInt("1.0");
}
catch(Exception e){
System.out.println("Exception occurred");
}
catch(RuntimeException ex){
System.out.println("RuntimeException");
} Exception
}} occurred
consider the code above & select the proper Exception RuntimeExce RuntimeExce does not
output from the options. occurred ption ption compile
176 Which three of the following are methods of
the Object class?

1.notify();
2.notifyAll();
3.isInterrupted();
4.synchronized();
5.interrupt();
6.wait(long msecs);
7.sleep(long msecs);
8.yield(); 1,2,4 2,4,5 1,2,6 2,3,4
177 In the given code snippet
try { int a = Integer.parseInt("one"); }
what is used to create an appropriate catch
block? (Choose all that apply.)
A. ClassCastException
B. IllegalStateException
C. NumberFormatException ClassCastEx NumberForm IllegalStateEx IllegalArgume
D. IllegalArgumentException ception atException ception ntException
178 class Trial{
public static void main(String[] args){
try{
System.out.println("One");
int y = 2 / 0;
System.out.println("Two");
}
catch(RuntimeException ex){
System.out.println("Catch");
}
finally{
System.out.println("Finally");
} One Two One Catch One Two
}} Catch Finally One Catch Finally Catch
179 Which digit,and in what order,will be printed
when the following program is run?

Public class MyClass {


public static void main(String[] args) {
int k=0;
try {
int i=5/k;
}
catch(ArithmeticException e) {
System.out.println("1");
}
catch(RuntimeException e) {
System.out.println("2");
return;
}
catch(Exception e) {
System.out.println("3");
}
finally{
System.out.println("4");
} The program The program The program
System.out.println("5"); The program will only print will only print will only print
} will only print 1 and 4 in 1,2 and 4 in 1 ,4 and 5 in
} 5 order order order
180 We cannot
class Trial{ have a try
public static void main(String[] args){ We cannot block block
try{ have a try without a
System.out.println("Java is portable"); Java is block without catch / finally Nothing is
}}} portable a catch block block diaplayed
181 class Animal { public String noise() { return
"peep"; } }
class Dog extends Animal {
public String noise() { return "bark"; }
}
class Cat extends Animal {
public String noise() { return "meow"; }
}
class try1{
public static void main(String[] args){
Animal animal = new Dog();
Cat cat = (Cat)animal;
System.out.println(cat.noise());
}} An exception
consider the code above & select the proper Compilation is thrown at
output from the options. bark meow fails runtime.
182 Given:
class X implements Runnable
{
public static void main(String args[])
{
/* Some code */
} X run = new
public void run() {} X(); Thread t Thread t = Thread t =
} = new Thread t = new new
Which of the following line of code is suitable Thread(run); new Thread(); Thread(X);
to start a thread ? t.start(); Thread(X); x.run(); t.start();
183

Variables can
If a class has be protected
synchronized from
code, concurrent
multiple access
A static threads can problems by When a
method still access marking them thread
cannot be the with the sleeps, it
synchronized nonsynchroni synchronized releases its
Which statement is true? . zed code. keyword. locks
184 Consider the following code and choose the
correct option:
class Test{
static void display(){
throw new RuntimeException();
}
public static void main(String args[]){
try{display();
}catch(Exception e){ } Compiles but
catch(RuntimeException re){} Compiles and Compilation exception at
finally{System.out.println("exit");}}} exit no output fails runtime
185
Given:
public class ExceptionTest
{
class TestException extends Exception {}
public void runTest() throws TestException
{}
public void test() /* Line X */
{
runTest();
}
} throws
At Line X, which code is necessary to make No code is throws throw RuntimeExce
the code compile? necessary Exception Exception ption
186 Implement Implement Extend
java.lang.Run Extend java.lang.Thr java.lang.Run
nable and java.lang.Thr ead and nable and
implement ead and implement override the
Which two can be used to create a new the run() override the the start() start()
Thread? method. run() method. method. method.
187
Except in
An Error that case of VM
might be shutdown, if
thrown in a a try block
Multiple catch method must starts to
A try statements be declared execute, a
statement can catch the as thrown by correspondin
must have at same class of that method, g finally block
least one exception or be handled will always
correspondin more than within that start to
Choose the correct option: g catch block once. method. execute.
188 class PropagateException{
public static void main(String[] args){
try{
method();
System.out.println("method() called");
}
catch(ArithmeticException ex){
System.out.println("Arithmetic Exception");
}
catch(RuntimeException re){
System.out.println("Runtime Exception");
}}
static void method(){
int y = 2 / 0; Arithmetic
}} Exception
consider the code above & select the proper Arithmetic Runtime Runtime compilation
output from the options. Exception Exception Exception error
189 Given:
static void test() {
try {
String x = null;
System.out.print(x.toString() + " ");
}
finally { System.out.print("finally "); }
}
public static void main(String[] args) {
try { test(); }
catch (Exception ex) {
System.out.print("exception "); }
} Compilation finally
What is the result? null fails. exception finally
190 Given two programs:
1. package pkgA;
2. public class Abc {
3. int a = 5;
4. protected int b = 6;
5. public int c = 7;
6. }

3. package pkgB;
4. import pkgA.*;
5. public class Def {
6. public static void main(String[] args) {
7. Abc f = new Abc();
8. System.out.print(" " + f.a);
9. System.out.print(" " + f.b);
10. System.out.print(" " + f.c);
11. } Compilation Compilation Compilation
12. } fails with an fails with an fails with an
What is the result when the second program error on line 5 followed by error on line error on line
is run? (Choose all that apply) 9 an exception 7 8
191

Consider the following code:

System.out.print("Start ");
try
{
System.out.print("Hello world");
throw new FileNotFoundException();
}
System.out.print(" Catch Here "); /* Line 7 */
catch(EOFException e)
{
System.out.print("End of file exception");
}
catch(FileNotFoundException e)
{
System.out.print("File not found");
}
Code output:
given that EOFException and Code output: Start Hello
Code output:
FileNotFoundException are both subclasses Start Hello world Catch
Start Hello
of IOException. If this block of code is pasted The code will world File Not Here File not
world End of
in a method, choose the best option. not compile. Found found.
file exception.
192 Any
Any statement
catch(X x) statement that can
can catch that can throw an
subclasses of The Error throw an Exception
X where X is class is a Error must be must be
a subclass of RuntimeExce enclosed in a enclosed in a
Which of the following statements is true? Exception. ption. try block. try block.
193 Consider the following code and choose the
correct option:
int array[] = new int[10]; compiles does not none of the
array[-1] = 0; successfully compile runtime error listed options
194 What will be the output of the program?

public class RTExcept


{
public static void throwit ()
{
System.out.print("throwit ");
throw new RuntimeException();
}
public static void main(String [] args)
{
try
{
System.out.print("hello ");
throwit();
}
catch (Exception re )
{
System.out.print("caught ");
}
finally
{
System.out.print("finally ");
} hello throwit
System.out.println("after "); RuntimeExce hello throwit
} hello throwit Compilation ption caught caught finally
} caught fails after after
195 What is the keyword to use when the access
of a method has to be restricted to only one
thread at a time volatile synchronized final private
196 Consider the following code and choose the
correct option:
class Test{
public static void parse(String str) {
try { int num = Integer.parseInt(str);
} catch (NumberFormatException nfe) {
num = 0; } finally { NumberForm
System.out.println(num); atException ParseExcepti
} } public static void main(String[] args) { thrown at Compilation on thrown at
parse("one"); } 0 runtime fails runtime
197 public static void parse(String str) {
try {
float f = Float.parseFloat(str);
} catch (NumberFormatException nfe) {
f = 0;
} finally { A
System.out.println(f); A NumberForm
} ParseExcepti atException
} on is thrown is thrown by
public static void main(String[] args) { by the parse the parse
parse("invalid"); Compilation method at method at
} 0 fails runtime. runtime.
198 Given the following program,which statements
are true? (Choose TWO) If run with
Public class Exception { one If run with
public static void main(String[] args) { arguments,th one
try { e program arguments,th
if(args.length == 0) return; If run with no If run with no will print the e program
System.out.println(args[0]); arguments,th arguments,th given will simply
}finally { e program e program argument print the
System.out.println("The end"); will produce will produce followed by given
}}} no output "The end" "The end" argument
199 Which can appropriately be thrown by a
programmer using Java SE technology to
create ClassCastEx NullPointerEx NoClassDefF NumberForm
a desktop application? ception ception oundError atException
200 ArrayIndexOu
Which of the following is a checked Arithmetic NullPointerEx tOfBoundsEx
exception? Exception IOException ception ception
201
Given:
11. class A {
12. public void process() {
System.out.print("A,"); }
13. class B extends A {
14. public void process() throws IOException {
15. super.process();
16. System.out.print("B,");
17. throw new IOException();
18. }
19. public static void main(String[] args) {
20. try { new B().process(); }
21. catch (IOException e) { Compilation Compilation
System.out.println("Exception"); } fails because
fails because
22. } A,B,Exceptio of an error in
of an error in
What is the result? Exception n line 20. line 14.
202 The The notify()
notifyAll() The notify() method
method must To call method is causes a
be called sleep(), a defined in thread to
from a thread must class immediately
synchronized own the lock java.lang.Thr release its
Which statement is true? context on the object ead locks.
203 class Trial{
public static void main(String[] args){
try{
System.out.println("Try Block");
}
finally{
System.out.println("Finally Block");
} Try Block Finally Block
}} Try Block Finally Block Finally Block Try Block
204 consider the code & choose the correct
output:
class Threads2 implements Runnable {

public void run() {


System.out.println("run.");
throw new RuntimeException("Problem");
}
public static void main(String[] args) {
Thread t = new Thread(new Threads2()); End of End of
t.start(); run method. method. run.
System.out.println("End of method."); java.lang.Run java.lang.Run java.lang.Run java.lang.Run
} timeExceptio timeExceptio timeExceptio timeExceptio
} n: Problem n: Problem n: Problem n: Problem
205 The exceptions for which the compiler doesn’t Checked Unchecked
enforce the handle or declare rule exceptions exceptions Exception all of these
206 Consider the code below & select the correct
ouput from the options:
public class Test{
Integer i;
int x;
Test(int y){
x=i+y;
System.out.println(x);
}
public static void main(String[] args) { Compiles but
new Test(new Integer(5)); Compilation error at run
}} 5 error time
207 Given:
public class TestSeven extends Thread {
private static int x;
public synchronized void doThings() {
int current = x;
current++;
x = current; Declaring the
} Synchronizin doThings()
public void run() { g the run() method as
doThings(); method static would
} would make make the An exception
} Compilation the class class thread- is thrown at
Which statement is true? fails. thread-safe. safe. runtime.
208 Consider the following code and choose the
correct option:
class Test{
static void display(){
throw new RuntimeException();
} public static void main(String args[]){
try{ display(); }catch(Exception e){
throw new NullPointerException();}
finally{try{ display();
}catch(NullPointerException e){ Compiles but
System.out.println("caught");} Compilation exception at
System.out.println("exit");}}} caught exit exit fails runtime
209 An object will
not be
garbage
An object is collected as
deleted as The finalize() long as it
soon as there The finilize() method will possible for a
are no more method will never be live thread to
Which statements describe guaranteed references eventually be called more access it
behaviour of the garbage collection and that denote called on than once on through a
finalization mechanisms? (Choose TWO) the object every object an object reference.
210 Which statement is true?
A. A class's finalize() method CANNOT be
invoked explicitly.
B. super.finalize() is called implicitly by any
overriding finalize() method.
C. The finalize() method for a given object is
called no more than once by the garbage
collector.
D. The order in which finalize() is called on
two objects is based on the order in which the
two
objects became finalizable. A B C D
211 Only the
garbage
collection
system can
Which of the following allows a programmer to Runtime.getR destroy an
destroy an object x? x.delete() x.finalize() untime().gc() object.
212 class X2
{
public X2 x;
public static void main(String [] args)
{
X2 x2 = new X2(); /* Line 6 */
X2 x3 = new X2(); /* Line 7 */
x2.x = x3;
x3.x = x2;
x2 = new X2();
x3 = x2; /* Line 11 */
}
}

after line 11 runs, how many objects are


eligible for garbage collection? 0 1 2 3
213 Given :
public class MainOne {
public static void main(String args[]) {
String str = "this is java";
System.out.println(removeChar(str,'s'));
}

public static String removeChar(String s,


char c) {
String r = "";
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) != c)
r += s.charAt(i);
}
return r;
}
} What would be the result? This is java Thi is java This i java Thi i java
214 Call
Set all System.gc()
references to passing in a
the object to reference to Garbage
new the object to collection
How can you force garbage collection of an values(null, be garbage Call cannot be
object? for example). collected System.gc() forced
215 Consider the following code and choose the
correct option:
public class X
{
public static void main(String [] args)
{
X x = new X();
X x2 = m1(x); /* Line 6 */
X x4 = new X();
x2 = x4; /* Line 8 */
doComplexStuff(); }
static X m1(X mx) {
mx = new X();
return mx; }}
After line 8 runs. how many objects are
eligible for garbage collection? 0 1 2 3
216 interface interface_1 {
void f1();
}
class Class_1 implements interface_1 {
void f1() {
System.out.println("From F1 funtion in
Class_1 Class");
}
}
public class Demo1 {
public static void main(String args[]) {
Class_1 o11 = new Class_1(); From F1
o11.f1(); function in Create an
} Class_1 Compile time object for Runtime
} Class error Interface only Error
217 Given:
class A {
final void meth() {
System.out.println("This is a final
method.");
}
}
class B extends A {
void meth() {
System.out.println("Illegal!");
}
}
class MyClass8{
public static void main(String[] args) {
A a = new A();
a.meth();
B b= new B(); This is a final
b.meth(); This is a final method illegal Some
} method Some error Compilation error
}What would be the result? illegal message error message
218 Which Man class properly represents the
relationship "Man has a best friend who is a
Dog"?
A)class Man extends Dog { }
B)class Man implements Dog { }
C)class Man { private BestFriend dog; }
D)class Man { private Dog bestFriend; } A B C D
219 What will be the output of the program?

class SuperClass
{
public Integer getLength()
{
return new Integer(4);
}
}

public class SubClass extends SuperClass


{
public Long getLength()
{
return new Long(5);
}

public static void main(String[] args)


{
SuperClass sp = new SuperClass();
SubClass sb = new SubClass();
System.out.println(
sp.getLength().toString() + "," +
sub.getLength().toString() );
} Compilation
} 4, 4 4, 5 5, 4 fails
220
Consider the code below & select the correct
ouput from the options:
abstract class Ab{ public int getN(){return 0;}}
class Bc extends Ab{ public int getN(){return
7;}}
class Cd extends Bc { public int getN(){return
47;}}
class Test{
public static void main(String[] args) {
Cd cd=new Cd();
Bc bc=new Cd();
Ab ab=new Cd();
System.out.println(cd.getN()+" "+ Compilation
bc.getN()+" "+ab.getN()); }} 000 47 7 0 error 47 47 47
221 interface A{}
class B implements A{}
class C extends B{}
public class Test extends C{
public static void main(String[] args) {
C c=new C();
/* Line6 */}}

Which code, inserted at line 6, will cause a


java.lang.ClassCastException? B b=c; A a2=(B)c; C c2=(C)(B)c; A a1=(Test)c;
222 Given :
What would be the result of compiling and
running the following program?
// Filename: MyClass.java
public class MyClass {
public static void main(String[] args) {
C c = new C();
System.out.println(c.max(13, 29));
}
}
class A {
int max(int x, int y) { if (x>y) return x; else The code will
return y; } fail to compile
} because the
class B extends A{ max() method
int max(int x, int y) { return super.max(y, x) - in B passes The code will
10; } the fail to compile
} arguments in because a
class C extends B { the call call to a The code will The code will
int max(int x, int y) { return super.max(x+10, super.max(y, max() method compile and compile and
y+10); } x) in the is print 23, print 29,
} wrong order. ambiguous. when run. when run.
223 The concept of multiple inheritance is
implemented in Java by

(A) extending two or more classes


(B) extending one class and implementing one
or more interfaces
(C) implementing two or more interfaces
(D) all of these (A) (A) & (C) (D) (B) & (C)
224
Given:
interface DoMath abstract class
{ AllMath
double getArea(int r); implements
} interface DoMath,
interface MathPlus class AllMath AllMath MathPlus { class AllMath
{ extends implements public double implements
double getVolume(int b, int h); DoMath { MathPlus { getArea(int MathPlus {
} double double rad) { return double
/* Missing Statements ? */ getArea(int r); getVol(int x, rad * rad * getArea(int
Select the correct missing statements. } int y); } 3.14; } } rad); }
225 Consider the following code and choose the
correct option:
class A{
void display(byte a, byte b){
System.out.println("sum of byte"+(a+b)); }
void display(int a, int b){
System.out.println("sum of int"+(a+b)); } Compiles but
public static void main(String[] args) { Compilation error at
new A().display(3, 4); }} sum of byte 7 error sum of int7 runtime
226
Consider the following code and choose the
correct option:
interface Output{
void display();
void show();
}
class Screen implements Output{
void display(){ System.out.println("display"); Compiles but
}public static void main(String[] args) { Compilation error at run Runs but no
new Screen().display();}} display error time output
227
class Animal {
void makeNoise() {System.out.println("generic
noise"); }
}
class Dog extends Animal {
void makeNoise() {System.out.println("bark"); }
void playDead() { System.out.println("roll
over"); }
}
class CastTest2 {
public static void main(String [] args) {
Dog a = (Dog) new Animal();
a.makeNoise();
}
}
consider the code above & select the proper
output from the options. run time error generic noise bark compile error
228
Consider the following code and choose the
correct option:
interface employee{
void saldetails();
void perdetails();
}
abstract class perEmp implements employee{
public void perdetails(){
System.out.println("per details"); }}
class Programmer extends perEmp{
public void saldetails(){
perdetails();
System.out.println("sal details"); }
public static void main(String[] args) {
perEmp emp=new Programmer(); sal details compilation per details
emp.saldetails(); }} sal details per details error sal details
229 Consider the code below & select the correct
ouput from the options:
class A{
static int sq(int n){
return n*n; }}
public class Test extends A{
static int sq(int n){
return super.sq(n); } Compiles but
public static void main(String[] args) { Compilation error at run
System.out.println(new Test().sq(3)); }} 3 error time 9
230
No—a Yes—the
No—a variable must variable can
Given: variable must always be an refer to any
public static void main( String[] args ) { always be an object No—a object whose
SomeInterface x; ... } object reference variable must class
Can an interface name be used as the type of reference type or a always be a implements
a variable type primitive type primitive type the interface
231 Consider the following code and choose the
correct option:
interface A{
int i=3;}
interface B{
int i=4;}
class Test implements A,B{
public static void main(String[] args) {
System.out.println(i); Compiles but
} compilation error at
} 3 4 error runtime
232 Given the following classes and declarations,
which statements are true?
// Classes
class A {
private int i;
public void f() { /* ... */ }
public void g() { /* ... */ }
}
class B extends A{
public int j;
public void g() { /* ... */ }
}
// Declarations:
A a = new A(); The B class The The The
B b = new B(); is a subclass statement statement a.j statement
Select the three correct answers. of A. b.f(); is legal = 5; is legal. a.g(); is legal
233 Which declaration can be inserted at (1)
without causing a compilation error?
interface MyConstants {
int r = 42; final double
int s = 69; circumferenc protected int
// (1) INSERT CODE HERE int total = e=2* CODE = int AREA = r
} total + r + s; Math.PI * r; 31337; * s;
234 What is the output for the following code:
abstract class One{
private abstract void test();
}
class Two extends One{
void test(){
System.out.println("hello");
}}
class Test{
public static void main(String[] args){
Two obj = new Two();
obj.test();
} run time compile time
} exception error hello hellohello
235
Consider the code below & select the correct
ouput from the options:

class Money {
private String country = "Canada";
public String getC() { return country; } }
class Yen extends Money {
public String getC() { return super.country; } Compiles but
public static void main(String[] args) { Compilation error at run
System.out.print(new Yen().getC() ); } } Canada error time null
236 we must use we must use
always always
extends and implements
later we must and later we we can use in extends and
When we use both implements & extends use must use any order its implements
keywords in a single java program then what implements extends not at all a can't be used
is the order of keywords to follow? keyword. keyword. problem together
237 Consider the code below & select the correct
ouput from the options:
1. public class Mountain {
2. protected int height(int x) { return 0; }
3. }
4. class Alps extends Mountain {
5. // insert code here
6. }
Which five methods, inserted independently at
line 5, will compile? (Choose three.)
A. public int height(int x) { return 0; }
B. private int height(int x) { return 0; }
C. private int height(long x) { return 0; }
D. protected long height(long x) { return 0; }
E. protected long height(int x) { return 0; } A,B,E A,C,D B,D,E C,D,E
238 Given:
interface DeclareStuff {
public static final int Easy = 3;
void doStuff(int t); }
public class TestDeclare implements
DeclareStuff {
public static void main(String [] args) {
int x = 5;
new TestDeclare().doStuff(++x);
}
void doStuff(int s) {
s += Easy + ++s;
System.out.println("s " + s);
} Compilation
} What is the result? s 14 s 16 s 10 fails.
239 Given:
interface A { public void methodA(); }
interface B { public void methodB(); }
interface C extends A,B{ public void
methodC(); } //Line 3 If you define If you define
class D implements B { D e = (D) D e = (D)
public void methodB() { } //Line 5 (new E()), (new E()),
} then then
class E extends D implements C { //Line 7 e.methodB() e.methodB()
public void methodA() { } invokes the invokes the
public void methodB() { } //Line 9 Compilation version of Compilation version of
public void methodC() { } fails, due to methodB() fails, due to methodB()
} an error in defined at an error in defined at
What would be the result? line 3 line 9 line 7 line 5
240 It must be It must be
used in the used in the
It can only be last first
used in the Only one statement of statement of
Which of the following statements is true parent's child class the the
regarding the super() method? constructor can use it constructor. constructor.
241
Consider the following code and choose the
correct option:
interface Output{
void display();
void show();
}
class Screen implements Output{
void show() {System.out.println("show");}
void display(){ System.out.println("display"); Compiles but
}public static void main(String[] args) { Compilation error at run Runs but no
new Screen().display();}} display error time output
242 Consider the following code and choose the
correct option:
class A{
void display(){ System.out.println("Hello A");
}}
class B extends A{
void display(){
System.out.println("Hello B"); }}
public class Test {
public static void main(String[] args) { Compiles but
B b=(B) new A(); Compilation error at
b.display(); }} Hello A error Hello B runtime
243 Consider the following code:
// Class declarations: Definitely
class Super {} legal at Definitely
class Sub extends Super {} runtime, but legal at
// Reference declarations: Legal at the cast runtime, and
Super x; compile time, operator the cast
Sub y; but might be (Sub) is not operator
Which of the following statements is correct Illegal at illegal at strictly (Sub) is
for the code: y = (Sub) x? compile time runtime needed. needed.
244 Given:
11. class ClassA {}
12. class ClassB extends ClassA {}
13. class ClassC extends ClassA {}
and:
21. ClassA p0 = new ClassA();
22. ClassB p1 = new ClassB();
23. ClassC p2 = new ClassC();
24. ClassA p3 = new ClassB();
25. ClassA p4 = new ClassC(); p1 =
Which TWO are valid? (Choose two.) p0 = p1; p2 = p4; (ClassB)p3; p1 = p2;
245 Consider the following code and choose the
correct option:
abstract class Car{
abstract void accelerate();
}
class Lamborghini extends Car{
@Override
void accelerate() {
System.out.println("90 mph"); }
void nitroBooster(){
System.out.print("150 mph"); }
public static void main(String[] args) {
Car mycar=new Lamborghini(); Compiles but
Lamborghini lambo=(Lamborghini) mycar; Compilation error at
lambo.nitroBooster();}} 150 mph error 90 mph runtime
246 Consider the following code and choose the
correct option:
class A{
void display(){ System.out.println("Hello A");
}}
class B extends A{
void display(){
System.out.println("Hello B"); }}
public class Test {
public static void main(String[] args) {
A a=new B(); Compiles but
B b= (B)a; Compilation error at
b.display(); }} Hello A error Hello B runtime
247 Because of
Because of single Because of Because of
single inheritance, single single
inheritance, Mammal can inheritance, inheritance,
Mammal can have no other Animal can Mammal can
A class Animal has a subclass Mammal. have no parent than have only have no
Which of the following is true: subclasses Animal one subclass siblings.
248
class Animal {
void makeNoise() {System.out.println("generic
noise"); }
}
class Dog extends Animal {
void makeNoise() {System.out.println("bark"); }
void playDead() { System.out.println("roll
over"); }
}
class CastTest2 {
public static void main(String [] args) {
Animal a = new Dog();
a.makeNoise();
}
}
consider the code above & select the proper
output from the options. run time error generic noise bark compile error
249 What will be the result when you try to
compile and run the following code?
class Base1 {
Base1() {
int i = 100;
System.out.println(i);
}
}

public class Pri1 extends Base1 {


static int i = 200;

public static void main(String argv[]) {


Pri1 p = new Pri1();
System.out.println(i);
} Error at 100 followed
} compile time 200 by 200 100
250 What is the output :
interface A{
void method1();
void method2();
}
class Test implements A{
public void method1(){
System.out.println("hello");}}
class RunTest{
public static void main(String[] args){
Test obj = new Test();
obj.method1();
}} hello compile error runtime error none
251 Given the following classes and declarations,
which statements are true?
// Classes
class Foo {
private int i;
public void f() { /* ... */ }
public void g() { /* ... */ }
}
class Bar extends Foo {
public int j;
public void g() { /* ... */ }
}
// Declarations: The Bar class The The The
Foo a = new Foo(); is a subclass statement a.j statement statement
Bar b = new Bar(); of Foo. = 5; is legal. b.f(); is legal. a.g(); is legal.
252 Given a derived class method which overrides by creating cannot call
one of it’s base class methods. With derived an instance because it is
class object you can invoke the overridden super of the base overridden in
base method using: keyword this keyword class derived class
253 Consider the following code and choose the
correct option:
abstract class Car{
abstract void accelerate();
}class Lamborghini extends Car{
@Override
void accelerate() {
System.out.println("90 mph");
} void nitroBooster(){
System.out.print("150 mph"); }
public static void main(String[] args) { Compiles but
Car mycar=new Lamborghini(); Compilation error at run
mycar.nitroBooster(); }} error time 90 mph 150 mph
254

Given:
class Pizza {
java.util.ArrayList toppings;
public final void addTopping(String topping) {
toppings.add(topping);
}
}
public class PepperoniPizza extends Pizza {
public void addTopping(String topping) {
System.out.println("Cannot add Toppings");
}
public static void main(String[] args) {
Pizza pizza = new PepperoniPizza();
pizza.addTopping("Mushrooms"); A
} The code NullPointerEx
} Compilation Cannot add runs with no ception is
What is the result? fails. Toppings output. thrown
255 Consider the following code and choose the
correct option:
interface console{
int line=10;
void print();}
class a implements console{
void print(){
System.out.print("A");} Compiles but
public static void main(String ar[]){ Compilation error at run Runs but no
new a().print();}} A error time output
256 private final public static
Which of these field declarations are legal in public int final static int static int int answer =
an interface? (Choose all applicable) answer = 42; answer = 42; answer = 42; 42;
257 Given :
No—there No—but a Yes—an
Day d; must always object of object can be
BirthDay bd = new BirthDay("Raj", 25); be an exact parent type assigned to a Yes—any
d = bd; // Line X match can be reference object can be
between the assigned to a variable of assigned to
Where Birthday is a subclass of Day. State variable and variable of the parent any reference
whether the code given at Line X is correct: the object child type. type. variable.
258
If both a If neither
subclass and super() nor
its superclass this() is
do not have declared as
A super() or any declared the first If super() is
this() call constructors, statement in the first
must always the implicit the body of a statement in
be provided default constructor, the body of a
explicitly as constructor of this() will constructor,
the first the subclass implicitly be this() can be
statement in will call inserted as declared as
the body of a super() when the first the second
Select the correct statement: constructor. run statement. statement
259
public final static final final data
data type data type type
Choose the correct declaration of variable in varaibale=inti static data varaiblename variablename
an interface: alization; type variable; ; =intialization;
260 Consider the following code and choose the
correct option:
abstract class Fun{
void time(){
System.out.println("Fun Time"); }}
class Run extends Fun{
void time(){
System.out.println("Fun Run"); }
public static void main(String[] args) { Compiles but
Fun f1=new Run(); Compilation error at
f1.time(); }} Fun Time error Fun Run runtime
261
interface Vehicle{
void drive();
}
final class TwoWheeler implements Vehicle{
int wheels = 2;
public void drive(){
System.out.println("Bicycle");
}
}
class ThreeWheeler extends TwoWheeler{
public void drive(){
System.out.println("Auto");
}}
class Test{
public static void main(String[] args){
ThreeWheeler obj = new ThreeWheeler();
obj.drive();
}}
consider the code above & select the proper
output from the options. Auto Bicycle Auto compile error runtime error
262
Consider the following code and choose the
correct option:
interface employee{
void saldetails();
void perdetails();
}
abstract class perEmp implements employee{
public void perdetails(){
System.out.println("per details"); }}
class Programmer extends perEmp{
public static void main(String[] args) {
perEmp emp=new Programmer(); sal details compilation per details
emp.saldetails(); }} sal details per details error sal details
263 All data members in an interface are by abstract and public and public ,static default and
default final abstract and final abstract
264 Consider the following code and choose the
correct option:
interface console{
int line;
void print();}
class a implements console{
public void print(){
System.out.print("A");} Compiles but
public static void main(String ar[]){ Compilation error at run Runs but no
new a().print();}} A error time output
265
An abstract
class is one
An abstract which
class is one contains An abstract
which some defined class is one
contains methods and which
general some contains only Abstract
Which of the following is correct for an purpose undefined static class can be
abstract class. (Choose TWO) methods methods methods declared final
266

abstract class
Vehicle {
abstract class abstract class abstract abstract void
Vehicle { Vehicle { Vehicle { display(); {
Which of the following defines a legal abstract abstract void abstract void abstract void System.out.pr
class? display(); } display(); } display(); } intln("Car"); }}
267 Consider the code below & select the correct
ouput from the options:

class Mountain{
int height;
protected Mountain(int x) { height=x; }
public int getH(){return height;}}

class Alps extends Mountain{


public Alps(int h){ super(h); }
public Alps(){ this(100); }
public static void main(String[] args) {
System.out.println(new Alps().getH()); Compiles but
} Compilation error at run Compiles but
} 100 error time no output
268 Consider the given code and select the
correct output:

class SomeException {
}

class A {
public void doSomething() { }
} Compilation Compilation
of class A will of class B will
class B extends A { Compilation Compilation fail. fail.
public void doSomething() throws of both of both Compilation Compilation
SomeException { } classes A & classes will of class B will of class A will
} B will fail succeed succeed succeed
269 No—if a
class
implements
several Yes— either
interfaces, of the two
each variables can Yes—since
constant No—a class be accessed the
must be may not through : definitions
Is it possible if a class definition implements defined in implement interfaceNam are the same
two interfaces, each of which has the same only one more than e.variableNa it will not
definition for the constant? interface one interface me matter
270
The
An overriding parameter list
method can of an
declare that it overriding
throws method can
checked be a subset
Private A subclass exceptions of the
methods can override that are not parameter list
cannot be any method thrown by the of the method
overridden in in a method it is that it is
Select the correct statement: subclasses superclass overriding overriding
271 Consider the following code and choose the
correct option:
class A{
void display(){ System.out.println("Hello A");
}}
class B extends A{
void display(){
System.out.println("Hello B"); }}
public class Test {
public static void main(String[] args) {
A a=new B(); Compiles but
B b= a; Compilation error at
b.display(); }} Hello A error Hello B runtime
272 Helps the
compiler to
find the
source file
that
corresponds
to a class, Helps
when it does Javadoc to
not find a Helps JVM to build the
Which of the following option gives one To maintain class file find and Java
possible use of the statement 'the name of the the uniform while execute the Documentati
public class should match with its file name'? standard compiling classes on easily
273
Holds the Holds the
location of Holds the location of
Core Java location of User Defined Holds the
Class Library Java classes, location of
Which of the following statement gives the (Bootstrap Extension packages Java
use of CLASSPATH? classes) Library and JARs Software
274
Sub
Packages Packages packages
can contain can contain should be
both Classes non-java declared as
Packages and elements private in
can contain Interfaces such as order to deny
Which of the following are true about only Java (Compiled images, xml importing
packages? (Choose 2) Source files Classes) files etc. them
275 Which of the following options give the valid
argument types for main() method? (Choose
2) String [][]args String args[] String[] args[] String[] args
276
[email protected]
Which of the following options give the valid dollorpack.$p _score.pack. [email protected]
package names? (Choose 3) ack.$$pack $$.$$.$$ __pack erp@ckage
277 Object class
provides the
Object class method for
has the core Set
Object class methods for implementati
Object class cannot be thread on in
Which of the following statements are true is an abstract instantiated synchronizati Collection
regarding java.lang.Object class? (Choose 2) class directly on framework
278 Java
Java Java Runtime Database
The term 'Java Platform' refers to Compiler Environment Connectivity Java
________________. (Javac) (JRE) (JDBC) Debugger
279 registerDriver
() method
and
Which of the following methods are needed registerDriver Class.forNam Class.forNam getConnectio
for loading a database driver in JDBC? () method e() e() n
280
Using the
static method
registerDriver
() method
Using which is Either
forName() available in forName() or
which is a DriverManag registerDriver None of the
how to register driver class in the memory? static method er Class. () given options
281 Give Code snipet:
{// Somecode
ResultSet rs = st.executeQuery("SELECT *
FROM survey");

while (rs.next()) {
String name = rs.getString("name");
System.out.println(name);
}

rs.close();
// somecode
} What should be imported related to java.sql.Resu java.sql.Drive java.sql.Drive java.sql.Conn
ResultSet? ltSet r rManager ection
282
Consider the following code & select the
correct option for output.
String sql ="select empno,ename from emp";
PreparedStatement
pst=cn.prepareStatement(sql);
System.out.println(pst.toString());
ResultSet rs=pst.executeQuery(); will show first Compiles but
System.out.println(rs.getString(1)+ " employee Compilation error at run Compiles but
"+rs.getString(2)); record error time no output
283
Which of the following methods finds the Connection.g ResultSetMet DatabaseMet Database.get
maximum number of connections that a etMaxConne aData.getMa aData.getMa MaxConnecti
specific driver can obtain? ctions xConnections xConnections ons
284 By default all JDBC transactions are
autocommit. State TRUE/FALSE. true false
285 DriverManag Driver ResultSet Statement
getConnection() is method available in? er Class Interface Interface Interface
286 A) By default, all JDBC transactions are auto
commit
B) PreparedStatement suitable for dynamic
sql and requires one time compilation
C) with JDBC it is possible to fetch information Only A and B Only B and C Both A and C
about the database is TRUE is True is TRUE All are TRUE
287 It returns int
value as
mentioned
below: > 0 if
many
columns
Contain Null
Value < 0 if
It returns true no column
when last contains Null
There is no read column Value = 0 if
such method contain SQL one column
What is the use of wasNull() in ResultSet in ResultSet NULL else contains Null none of the
interface? interface returns false value listed options
288 Given :
public class MoreEndings {
public static void main(String[] args) throws
Exception {
Class driverClass =
Class.forName("sun.jdbc.odbc.JdbcOdbcDrive
r");
DriverManager.registerDriver((Driver)
driverClass.newInstance()); java.sql.Drive
// Some code r
} Inorder to compile & execute this code, what java.sql.Drive java.sql.Drive java.sql.Drive java.sql.Data
should we import? r r rManager Source
289
Which of the following method can be used to
execute to execute all type of queries i.e. executeAllSQ executeQuer
either Selection or Updation SQL Queries? executeAll() L() execute() y()
290
Which method will return boolean when we try executeUpda executeSQL( executeQuer
to execute SQL Query from a JDBC program? te() ) execute() y()
291
Cosider the following code & select the
correct output.
String sql ="select rollno, name from student";
PreparedStatement
pst=cn.prepareStatement(sql);
System.out.println(pst.toString());
ResultSet rs=pst.executeQuery(); Compiles but
while(rs.next()){ will show only Compilation error at run
System.out.println(rs.getString(3)); } name error will show city time
292
It is possible to insert/update record in a table
by using ResultSet. State TRUE/FALSE true false
293 Read only, Updatable,
What is the default type of ResultSet in JDBC Read Only, Updatable, Scroll Scroll
applications? Forward Only Forward only Sensitive sensitive
294 An application can connect to different
Databases at the same time. State
TRUE/FALSE. true false
295 A) It is not possible to execute select query
with execute() method
B) CallableStatement can executes store Both A and B Only A is Only B is Both A and B
procedures only but not functions is FALSE TRUE TRUE is TRUE
296 A) When one use callablestatement, in that
case only parameters are send over network
not sql query.
B) In preparestatement sql query will compile Both A and B Both A and B Only A is Only B is
for first time only is FALSE is TRUE TRUE TRUE
297 Consider the code below & select the correct
ouput from the options:

String sql ="select * from ?";


String table=" txyz ";
PreparedStatement
pst=cn.prepareStatement(sql);
pst.setString(1,table );
ResultSet rs=pst.executeQuery(); will show all Compiles but Compiles but
while(rs.next()){ row of first Compilation error at run run without
System.out.println(rs.getString(1)); } column error time output
298
Sylvy wants to develop Student management
system, which requires frequent insert
operation about student details. In order to
insert student record which statement CallableState PreparedStat
interface will give good performance Statement ment ement RowSet
299 class CreateFile{
public static void main(String[] args) {
try {
File directory = new File("c"); //Line 13
File file = new File(directory,"myFile");
if(!file.exists()) {
file.createNewFile(); //Line 16
}}
catch(IOException e) { Line 13
e.printStackTrace } creates a
}}} Line 13 directory
If the current direcory does not consists of Line 16 is An exception creates a File named “c” in
directory "c", Which statements are true ? never is thrown at object named the file
(Choose TWO) executed runtime “c” system.
300 1) Driver 2)
Connection
3) ResultSet 1) Driver 2)
4) Connection
ResultSetMet 3) ResultSet
aData 5) 4)
Statement 6) ResultSetMet
DriverManag aData 5)
er 7) Statement 6)
1) Driver 2) PreparedStat PreparedStat
Connection ement 8) ement 7)
3) ResultSet Callablestate Callablestate
4) ment 9) ment 8)
Which of the following options contains only DriverManag DataBaseMet DataBaseMet All of the
JDBC interfaces? er 5) Class aData aData given options
301 Consider the code below & select the correct
ouput from the options:

public class Test {


public static void main(String [] args) {
int x = 5;
boolean b1 = true;
boolean b2 = false;
if ((x == 4) && !b2 )
System.out.print("1 ");
System.out.print("2 ");
if ((b2 = true) && b1 )
System.out.print("3 "); } 23 13 2 3
302 Which three are legal array declarations? int [] char [] int [6] Dog myDogs
(Choose THREE) myScores []; myChars; myScores; [];
303 Consider the given code and select the
correct output:
class Test{
public static void main(String[] args){
int num1 = 012;
int num2 = 0x110; Compiles but
int sum =num1+=num2; error at run Compilation
System.out.println("Ans = "+sum); }} 26 282 time error
304 Say that class Rodent has a child class Rat
and another child class Mouse. Class Mouse
has a child class PocketMouse. Examine the
following

Rodent rod;
Rat rat = new Rat();
Mouse mos = new Mouse();
PocketMouse pkt = new PocketMouse();

Which one of the following will cause a


compiler error? rod = mos pkt = rat pkt = null rod = rat
305 Consider the code below & select the correct
ouput from the options:
class Test{
public static void main(String[] args) {
parse("Four"); } A
static void parse(String s){ A NumberForm
try { ParseExcepti atException
double d=Double.parseDouble(s); on is thrown is thrown by
}catch(NumberFormatException nfe){ by the parse the parse
d=0.0; }finally{ Compilation method at method at
System.out.println(d); } }} 0 error runtime runtime
306 Consider the code below & select the correct
ouput from the options:
class A{
public int a=7;
public void add(){
this.a+=2; System.out.print("a"); }}

public class Test extends A{


public int a=2;
public void add(){
this.a+=2; System.out.print("t"); }
public static void main(String[] args) {
A a =new Test();
a.add(); Compilation
System.out.print(a.a); }} t7 t9 a9 error
307 What will be the output of the program?

public class CommandArgsTwo


{
public static void main(String [] argh)
{
int x;
x = argh.length;
for (int y = 1; y <= x; y++)
{
System.out.print(" " + argh[y]);
}
}
}

and the command-line invocation is An exception


is thrown at
> java CommandArgsTwo 1 2 3 012 23 000 runtime
308
What will be the result of the following
program?
public class Init {
String title;
boolean published;
static int total;
static double maxPrice;
public static void main(String[] args) {
Init initMe = new Init();
double price;
if (true)
price = 100.00; The program The program The program
System.out.println("|" + initMe.title + "|" + will compile, will compile, The program will compile,
initMe.published + "|" + and print and print will compile, and print
Init.total + "|" + Init.maxPrice + "|" + price+ "|"); |null|false|0|0. |null|true|0|0. and print | |null|false|0|0.
} 0|0.0|, when 0|100.0|, |false|0|0.0|0. 0|100.0|,
} run when run 0|, when run when run
309 Here is the general syntax for method
definition: The
The returnValue
accessModifier returnType methodName( returnValue must be the
parameterList ) can be any same type as
{ type, but will the
Java statements be returnType,
The automatically or be of a
return returnValue; returnValue converted to If the type that can
} must be returnType returnType is be converted
exactly the when the void then the to returnType
same type as method returnValue without loss
What is true for the returnType and the the returns to the can be any of
returnValue? returnType caller. type information.
310 Consider the following code and choose the
correct option:
class Test{
class A{ static int x=3; }
static void display(){
System.out.println(A.x); } Compiles but
public static void main(String[] args) { Compilation error at run
display(); }} 3 error time 0
311 Which of the following lines of code will
compile without warning or error?
1) float f=1.3;
2) char c="a";
3) byte b=257;
4) boolean b=null; Line 1, Line
5) int i=10; Line 3 3, Line 5 Line 1, Line 5 Line 5
312 Consider the following code and choose the
correct option:
class Test{
interface Y{
void display(); }
public static void main(String[] args) {
new Y(){
public void display(){ Compiles but Compiles but
System.out.println("Hello World"); } Compilation error at run run without
}.display(); }} Hello World error time output
313 Consider the following code and choose the
correct option:
class Test{
static class A{
interface X{
int z=4; } }
static void display(){
System.out.println(A.X.z); } Compiles but
public static void main(String[] args) { Compilation error at run
display(); }} 4 error time
314
What is the output of the following program?
public class MyClass
{
public static void main( String[] args )
{
private static final int value =9;
float total;
total = value + value / 2;
System.out.println( total );
} Compilation
} 0 13.5 13 Error
315 Which of the given options is similar to the
following code: value = value sum = sum +
+ sum; sum = 1; value = value = value value = value
value += sum++ ; sum + 1; value + sum; + sum; + ++sum;
316 What will happen if you attempt to compile
and run the following code?
Integer ten=new Integer(10);
Long nine=new Long (9);
System.out.println(ten + nine);
int i=1; 19 followed 19 follwed by Compile time 10 followed
System.out.println(i + ten); by 11 20 error by 1
317 Identify the statements that are correct:
(A) int a = 13, a>>2 = 3
(B) int b = -8, b>>1 = -4
(C) int a = 13, a>>>2 = 3 (A), (B), (C) &
(D) int b = -8, b>>>1 = -4 (A), (B) & (C) (D) (C) & (D) (A) & (B)
318 Consider the following code:
int x, y, z;
y = 1;
z = 5;
x = 0 - (++y) + z++;
After execution of this, what will be the values x = -7, y = 1, x = 3, y = 2, z x = 4, y = 1, z x = 4, y = 2, z
of x, y and z? z=5 =6 =5 =6
319 Here is the general syntax for method
definition:

accessModifier returnType methodName(


parameterList ) It can be
{ omitted, but if
Java statements not omitted
there are The access It can be
return returnValue; several modifier must omitted, but if
} It must choices, agree with not omitted it
always be including the type of must be
private or private and the return private or
What is true for the accessModifier? public public value public
320 What will be the output of the program?

public class CommandArgs


{
public static void main(String [] args)
{
String s1 = args[1];
String s2 = args[2];
String s3 = args[3];
String s4 = args[4];
System.out.print(" args[2] = " + s2);
}
}

and the command-line invocation is An exception


is thrown at
> java CommandArgs 1 2 3 4 args[2] = 2 args[2] = 3 args[2] = null runtime
321 Consider the following code snippet:
int i = 10;
int n = ++i%5;
What are the values of i and n after the code
is executed? 10, 1 11, 1 10,0 11,0
322
Which will legally declare, construct, and int [] myList = int [] myList = int myList [] [] int myList [] =
initialize an array? {"1", "2", "3"}; (5, 8, 2); = {4,9,7,0}; {4, 3, 7};
323 Consider the code below & select the correct
ouput from the options:
public class Test {
public static void main(String[] args) {
int x=5;
Test t=new Test();
t.disp(x);
System.out.println("main X="+x);
}
void disp(int x) {
System.out.println("disp X = "+x++); disp X = 6 disp X = 5 disp X = 5 Compilation
}} main X=6 main X=5 main X=6 error
324 How many objects and reference variables are
created by the following lines of code? Two objects Three objects Four objects Two objects
Employee emp1, emp2; and three and two and two and two
emp1 = new Employee() ; reference reference reference reference
Employee emp3 = new Employee() ; variables. variables variables variables.
325 A) The purpose of the method overriding is to
perform different operation, though input
remains the same.
B) one of the important Object Oriented
principle is the code reusability that can be Only A is Only B is Both A and B Both A and B
achieved using abstraction TRUE True is True is FALSE
326 class Test{
public static void main(String[] args){
byte b=(byte) (45 << 1);
b+=4;
System.out.println(b); }} Compiles but
What should be the output for the code written error at run Compilation
above? 48 94 time error
327 What is the value of y when the code below is
executed?
int a = 4;
int b = (int)Math.ceil(a % 3 + a / 3.0); 1 2 3 4
328 Consider the following code and choose the
correct option:
class Test{
class A{
interface X{
int z=4; } }
static void display(){
System.out.println(new A().X.z); } Compiles but
public static void main(String[] args) { Compilation error at run
display(); }} 0 error time 4
329 Consider the code below & select the correct
ouput from the options:
public class Test {
public static void main(String[] args) {
String[] elements = { "for", "tea", "too" };
String first = (elements.length > 0) The variable The variable Compiles but
?elements[0] : null; Compilation first is set to first is set to error at
System.out.println(first); }} error null. elements[0]. runtime
330 Given the following piece of code:
public class Test {
public static void main(String args[]) {
int i = 0, j = 5 ;
for( ; (i < 3) && (j++ < 10) ; i++ ) {
System.out.print(" " + i + " " + j );
}
System.out.print(" " + i + " " + j );
}
} 0 6 1 7 2 8 3 0 6 1 7 2 8 3 0 5 1 5 2 5 3 compilation
what will be the output? 8 9 5 fails
331 Given
class MybitShift
{
public static void main(String [] args)
{
int a = 0x5000000;
System.out.print(a + " and ");
a = a >>> 25;
System.out.println(a);
} 83886080 2 and 2 and - 83886080
} and -2 83886080 83886080 and 2
332 Consider the code below & select the correct
ouput from the options:

public class Test {


int squares = 81;
public static void main(String[] args) {
new Test().go(); }
void go() {
incr(++squares);
System.out.println(squares); } Compilation
void incr(int squares) { squares += 10; } } 92 91 error 82
333 class C{
public static void main (String[] args) {
byte b1=33; //1
b1++; //2
byte b2=55; //3
b2=b1+1; //4
System.out.println(b1+""+b2);
}}
Consider the code above & select the correct compile time compile time runtime
output. error at line 2 error at line 4 prints 34,56 exception
334 What will be the output of the program ?

public class Test


{
public static void main(String [] args)
{
signed int x = 10;
for (int y=0; y<5; y++, x--)
System.out.print(x + ", "); An exception
} Compilation is thrown at
} 10, 9, 8, 7, 6, 9, 8, 7, 6, 5, fails runtime
335 1. public class LineUp {
2. public static void main(String[] args) {
3. double d = 12.345;
4. // insert code here
5. }
6. }
Which code fragment, inserted at line 4,
produces the output | 12.345|?

A. System.out.printf("|%7f| \n", d);


B. System.out.printf("|%3.7f| \n", d);
C. System.out.printf("|%7.3d| \n", d);
D. System.out.printf("|%7.3f| \n", d); A B C D
336 Consider the following code and choose the
correct option:
class Test{
interface Y{
void display(); }
public static void main(String[] args) {
Y y=new Y(){
public void display(){ Compiles but Compiles but
System.out.println("Hello World"); } }; Compilation error at run run without
y.display(); }} Hello World error time output
337 class Test{
public static void main(String[] args){
int var;
var = var +1;
System.out.println("var ="+var);
}} compiles and
consider the code above & select the proper runs with no does not
output from the options. output var = 1 compile run time error
338 State the class relationship that is being
implemented by the following code:
class Employee
{
private int empid;
private String ename;
public double getBonus()
{
Accounts acc = new Accounts();
return acc.calculateBonus();
}
}

class Accounts
{
public double calculateBonus(){//method's
code} Simple
} Aggregation Association Dependency Composition
339
Given classes A, B, and C, where B extends
A, and C extends B, and where all classes
implement the instance method void doIt().
How can the doIt() method in A be It is not his.super.doIt ((A)
called from an instance method in C? possible super.doIt() () this).doIt();
340 int [] a =
Which of the following will declare an array Array a = {23,22,21,20, int a [] = new
and initialize it with five numbers? new Array(5); 19}; int[5]; int [5] array;
341 Which of the following are correct variable
names? (Choose TWO) int #ss; int 1ah; int _; int $abc;
342 What is the output of the following:

int a = 0;
int b = 10;

a = --b ;
System.out.println("a: " + a + " b: " + b ); a: 9 b:11 a: 10 b: 9 a: 9 b:9 a: 0 b:9
343 As per the following code fragment, what is
the value of a?
String s;
int a;
s = "Foolish boy.";
a = s.indexOf("fool"); -1 0 4 random value
344 Consider the following code snippet:
int i = 10;
int n = i++%5;
What are the values of i and n after the code
is executed? 10, 1 11, 1 10,0 11,0
345 Consider the following code and choose the
correct output:

int value = 0;
int count = 1;
value = count++ ;
System.out.println("value: "+ value + " count: value: 0 value: 0 value: 1 value: 1
" + count); count: 0 count: 1 count: 1 count: 2
346 Consider the following code and select the
correct output:
class Test{
interface Y{
void display(); }
public static void main(String[] args) {
new Y(){
public void display(){ Compiles but Compiles but
System.out.println("Hello World"); } }; Compilation error at run run without
}} Hello World error time output
347
What is the output of the following program?
public class demo {
public static void main(String[] args) {
int arr[5];
for (int i = 0; i < arr.length; i++) {
arr[i] = arr[i] + 10;
}
for (int j = 0; j < arr.length; j++)
System.out.println(arr[j]); A sequence
A sequence of Garbage
} of five 10's Values are compile time Compiles but
} are printed printed Error no output
348 Which of the following methods registers a
thread in a thread scheduler? run(); construct(); start(); register();
349 class PingPong2 {
synchronized void hit(long n) {
for(int i = 1; i < 3; i++)
System.out.print(n + "-" + i + " ");
}
}
public class Tester implements Runnable {
static PingPong2 pp2 = new PingPong2();
public static void main(String[] args) {
new Thread(new Tester()).start();
new Thread(new Tester()).start();
}
public void run() {
pp2.hit(Thread.currentThread().getId()); } The output The output The output The output
} could be 5-1 could be 6-1 could be 6-1 could be 6-1
Which statement is true? 6-1 6-2 5-2 6-2 5-1 5-2 5-2 6-2 5-1 6-2 5-1 7-1
350 Consider the following code and choose the
correct option:
class Cthread extends Thread{
public void run(){
System.out.print("Hi");}
public static void main (String args[]){
Cthread th1=new Cthread(); will print Hi
th1.run(); twice and
th1.start(); throws
th1.run(); Exception at will print Hi Compilation will print Hi
}} run time Thrice error once
351 class Cthread extends Thread{
public void run(){
System.out.print("Hi");}
public static void main (String args[]){
Cthread th1=new Cthread(); will print Hi
th1.run(); twice and
th1.start(); throws
th1.start(); will start two will print Hi exception at
}} thread Once will not print runtime
352 Consider the following code and choose the
correct option:
class Cthread extends Thread{
Cthread(){start();}
public void run(){
System.out.print("Hi");} will create
public static void main (String args[]){ two child
Cthread th1=new Cthread(); threads and will not create
Cthread th2=new Cthread(); display Hi compilation any child will display Hi
}} twice error thread once
353 Which of the following methods are defined in
class Thread? (Choose TWO) start() wait() notify() run()
354 The following block of code creates a Thread
using a Runnable target:

Runnable target = new MyRunnable(); public class


public class
Thread myThread = new Thread(target); MyRunnableMyRunnable public class public class
implementsextends MyRunnable MyRunnable
Which of the following classes can be used to Runnable{pu
Runnable{pu implements extends
create the target, so that the preceding code blic void blic void Runnable{voi Object{public
compiles correctly? run(){}} run(){}} d run(){}} void run(){}}
355 Extend Implement Implement
Extend java.lang.Run java.lang.Thr java.lang.Run
java.lang.Thr nable and ead and nable and
ead and override the implement implement
Which of the following statements can be override the start() the run() the run()
used to create a new Thread? (Choose TWO) run() method. method. method. method
356 What will be the output of the program?

class MyThread extends Thread


{
MyThread() {}
MyThread(Runnable r) {super(r); }
public void run()
{
System.out.print("Inside Thread ");
}
}
class MyRunnable implements Runnable
{
public void run()
{
System.out.print(" Inside Runnable");
}
}
class Test
{
public static void main(String[] args)
{
new MyThread().start();
new MyThread(new
MyRunnable()).start(); Prints "Inside Prints "Inside Throws
} Thread Inside Does not Thread Inside exception at
} Thread" compile Runnable" runtime
357 A) Multiple processes share same memory
location
B) Switching from one thread to another is
easier than switching from one process to
another
C) Thread makes it possible to maximize
resource utilization All are Only B and C Only A and B Only C and D
D) Process is a light weight program FALSE is TRUE is TRUE is TRUE
358 A) Exception is the superclass of all errors
and exceptions in the java language
B) RuntimeException and its subclasses are Only A is Only B is Both A and B Both A and B
unchecked exception. TRUE TRUE are TRUE are FALSE
359 What will be the output of the program?

class MyThread extends Thread


{
public static void main(String [] args)
{
MyThread t = new MyThread();
t.start();
System.out.print("one. ");
t.start();
System.out.print("two. ");
}
public void run()
{
System.out.print("Thread "); An exception It prints The output
} Compilation occurs at "Thread one. cannot be
} fails runtime. Thread two." determined.
360 Consider the following code and choose the
correct option:
class A implements Runnable{ int k;
public void run(){
k++; } Compiles but
public static void main(String args[]){ throws run
A a1=new A(); It will start a compilation time a1 is not a
a1.run();} new thread error Exception Thread
361 Given:
public class Threads4 {
public static void main (String[] args) {
new Threads4().go();
}
public void go() {
Runnable r = new Runnable() {
public void run() {
System.out.print("run");
}
};
Thread t = new Thread(r);
t.start(); The code
t.start(); The code executes
} An exception executes normally, but
} Compilation is thrown at normally and nothing is
What is the result? fails. runtime. prints "run". printed.
362 class Thread2 {
public static void main(String[] args) {
new Thread2().go(); }
public void go(){
Runnable rn=new Runnable(){
public void run(){
System.out.println("Good Day.."); } };
Thread t=new Thread(rn); The code
t.start(); executes
}} An exception normally and
what should be the correct output for the code Compilation is thrown at prints "Good prints Good
written above? fails. runtime. Day.." Day.. Twice
363 public class MyRunnable implements
Runnable
{
public void run()
{
// some code here
} new new
} Runnable(My new new Thread(new
which of these will create and start this Runnable).st Thread(MyRu MyRunnable( MyRunnable(
thread? art(); nnable).run(); ).start(); )).start();
364 Consider the following code and choose the
correct option:
class Nthread extends Thread{
public void run(){
System.out.print("Hi");} Will create
public static void main(String args[]){ two child
Nthread th1=new Nthread(); threads and will not create
Nthread th2=new Nthread(); display Hi compilation any child will display Hi
} twice error thread once
365 Assume the following method is properly
synchronized and called from a thread A on
an object B:

wait(2000); After the lock


After thread on B is
After calling this method, when will the thread A is notified, released, or Two seconds Two seconds
A become a candidate to get another turn at or after two after two after thread A after lock B is
the CPU? seconds. seconds. is notified. released.
366
wait(), notify() and notifyAll() methods belong Interrupt none of the
to ________ Object class Thread class class listed options
367 Consider the following code and choose the
correct option:
class Test {
public static void main(String[] args) {
new Test().display("hi", 1);
new Test().display("hi", "world", 2); }
public void display(String... s, int x) { Compilation
System.out.print(s[s.length-x] + " "); } } hi hi hi world world error
368 Consider the following code and choose the
correct option:
public class Test {
public static void main(String[] args) {
String name="Anthony Gomes";
int a=111; Compilation
System.out.println(name.indexOf(a)); }} 4 2 6 error
369 Given:
String test = "This is a test";
String[] tokens = test.split("\s");
System.out.println(tokens.length); Compilation
What is the result? 0 1 4 fails.
370
Consider the following code and choose the
correct option:
public class Test {
public static void main(String[] args) { Compiles but
String data="78"; Compilation exception at
System.out.println(data.append("abc")); }} 78abc abc78 error run time
371 Consider the following code and choose the
correct option:
public class Test {
public static void main(String[] args) {
String name="ALDPR7882E";
System.out.println(name.endsWith("E") &
name.matches("[A-Z]{5}[0-9]{4}[A-Z]"));}} false true 0 1
372 Examine this code:

String stringA = "Hello ";


String stringB = " World"; result = result =
String stringC = " Java"; stringA.conca result.concat( concat(String
String result; t( stringA, result+stringA A).concat(Stri
Which of the following puts a reference to stringB.conca stringB, +stringB+stri ngB).concat(
"Hello World Java" in result? t( stringC ) ); stringC ); ngC; StringC)
373 For two string objects obj1 and obj2:
A) Use of obj1 == obj2 tests whether two
String object references refer to the same
object
B) obj1.equals(obj2) compares the sequence Only A is Only B is Both A and B Both A and B
of characters in obj1 and obj2. TRUE TRUE is TRUE is FALSE
374 What is the result of the following:

String ring = "One ring to rule them all,\n";


String find = "One ring to find them.";

if ( ring.startsWith("One") && One ring to


find.startsWith("One") ) One ring to One ring to rule them
System.out.println( ring+find ); rule them all, rule them all, all,\n One
else One ring to One ring to ring to find Different
System.out.println( "Different Starts" ); find them. find them. them. Starts
375
The code will
Consider the following code and choose the fail to compile
correct option: because the
class MyClass { expression
String str1="str1"; str3.concat(st
String str2 ="str2"; r1) will not
String str3="str3"; result in a
str1.concat(str2); valid The program The program
System.out.println(str3.concat(str1)); argument for will print The program will print
} the println() str3str1str2,w will print str3str1,when
} method hen run str3,when run run
376 Given:
public class Theory {
public static void main(String[] args) {
String s1 = "abc";
String s2 = s1;
s1 += "d";
System.out.println(s1 + " " + s2 + " " +
(s1==s2));

StringBuffer sb1 = new StringBuffer("abc");


StringBuffer sb2 = sb1;
sb1.append("d");
System.out.println(sb1 + " " + sb2 + " " +
(sb1==sb2)); The second The first line The second
} line of output The first line of output is line of output
} is abcd abcd of output is abcd abc is abcd abc
Which are true? (Choose all that apply.) true abc abc false false false
377 class StringManipulation{
public static void main(String[] args){
String str = new String("Cognizant");
str.concat(" Technology");
StringBuffer sbf = new StringBuffer("
Solutions");
System.out.println(str+sbf);
}} Cognizant
consider the code above & select the proper Technology Cognizant Cognizant Technology
output from the options. Solutions Technology Solutions Solutions
378 What does this code write:

StringTokenizer stuff = new StringTokenizer(


"abc def+ghi", "+");
System.out.println( stuff.nextToken() );
System.out.println( stuff.nextToken() ); abc def abc def ghi abc def + abc def +ghi
379 Consider the following code and choose the
correct option:
public class Test {
public static void main(String[] args) {
StringBuffer sb = new
StringBuffer("antarctica"); Complies but
sb.delete(0,6); Compilation exception at
System.out.println(sb); }} tica anta error run time
380 Consider the following code and choose the
correct option:
public class Test {
public static void main(String[] args) {
String name="vikaramaditya";
System.out.println(name.substring(2,
5).toUpperCase().charAt(2));}} K A R I
381 Consider the following code and choose the
correct option:
public class Test {
public static void main(String[] args) {
StringBuffer sb = new
StringBuffer("antarctica");
sb.reverse();
sb.replace(2, 7, "c");
sb.delete(0,2);
System.out.println(sb); }} acctna iccratna ctna tna
382 Consider the following code and choose the
correct option:
class Test {
public static void main(String args[]) {
String s1 = "abc";
String s2 = "def";
String s3 = s1.concat(s2.toUpperCase( ) ); abcabcDEFD abcdefabcDE none of the
System.out.println(s1+s2+s3); } } abcdefabcdef EF F listed options
383 What will be the result when you attempt to
compile and run the following code?.
public class Conv
{
public static void main(String argv[]){
Conv c=new Conv();
String s=new String("ello");
c.amethod(s);
}

public void amethod(String s){


char c='H';
c+=s; Compilation Compilation Compilation
System.out.println(c); and output and output and output
} the string the string the string Compile time
} "Hello" "ello" elloH error
384 Consider the following code and choose the
correct option:
public class Test {
public static void main(String[] args) {
String name="Anthony Gomes";
System.out.println(name.replace('n', Compilation
name.charAt(3)).compareTo(name)); }} -6 6 0 error
385 Consider the following code and choose the
correct option:
class Test {
public static void main(String args[]) {
String name=new String("batman");
int ibegin=1;
char iend=3;
System.out.println(name.substring(ibegin,
iend)); Compilation
}} bat at atm error
386 Consider the following code and choose the
correct option:
public class Test {
public static void main(String[] args) {
StringBuffer sb=new
StringBuffer("YamunaRiver");
System.out.println(sb.capacity()); }} 10 27 24 11
387 Consider the following code and choose the
correct option:
public class Test {
public static void main(String[] args) {
StringBuffer sb = new
StringBuffer("antarctica");
sb.reverse();
sb.insert(4, 'r');
sb.replace(2, 4, "c");
System.out.println(sb); }} acitcratna acitrcratna accircratna accrcratna
388 A)A string buffer is a mutable sequence of
characters.
B) sequece of characters in the string buffer Only A is Only B is Both A and B Both A and B
can not be changed. TRUE TRUE is TRUE is FALSE
389 Examine this code:

String stringA = "Wild";


String stringB = " Irish";
String stringC = " Rose"; result = result =
String result; stringA.conca result.concat( concat(String
t( stringA, result+stringA A).concat(Stri
Which of the following puts a reference to stringB.conca stringB, +stringB+stri ngB).concat(
"Wild Irish Rose" in result? t( stringC ) ); stringC ); ngC; StringC)
390 Consider the following code and choose the
correct option:
class Test {
public static void main(String[] args) {
new Test().display(1,"hi");
new Test().display(2,"hi", "world" ); }
public void display(int x,String... s) { Compilation
System.out.print(s[s.length-x] + " "); }} hi hi hi world world error
391 Consider the following code and choose the
correct option:
public class Test {
public static void main(String[] args) {
String name="vikaramaditya";
System.out.println(name.codePointAt(2)+nam Compilation
e.charAt(3)); }} 203 204 205 error
392 Consider the following code and choose the
correct option:
public class Test {
public static void main(String[] args) { Compiles but
String data="7882"; exception at Compilation
data+=32; System.out.println(data); }} 7914 run time 788232 error
393 Which code can be inserted at Line X to print
"Equal"?
public class EqTest{
public static void main(String argv[]){
EqTest e=new EqTest();
}

EqTest(){
String s="Java";
String s2="java";
// Line X
{
System.out.println("Equal");
}else
{
System.out.println("Not equal");
}
} if(s.equals(s2 if(s.equalsIgn if(s.noCaseM
} if(s==s2) )) oreCase(s2)) atch(s2))
394 import java.io.*;
public class MyClass implements Serializable
{
private int a;
public int getA() { return a; }
publicMyClass(int a){this.a=a; }
private void writeObject( ObjectOutputStream
s)
throws IOException {
// insert code here
}
}

Which code fragment, inserted at line 15, will


allow Foo objects to be s.defaultWrit s.writeObject(
correctly serialized and deserialized? s.writeInt(x); s.serialize(x); eObject(); x);
395 FileOutputStr
eam fos =
FileOutputStr FileOutputStr DataOutputSt new
eam fos = eam fos = ream dos = FileOutputStr
new new new eam( new
FileOutputStr FileOutputStr DataOutputSt BufferedOutp
Which of the following opens the file eam( eam( ream( utStream(
"myData.stuff" for output first deleting any file "myData.stuff "myData.stuff "myData.stuff "myData.stuff
with that name? ", true ) ") ") ") )
396
import java.io.*;
public class MyClass implements Serializable
{

private Tree tree = new Tree();

public static void main(String [] args) {


MyClass mc= new MyClass();
try {
FileOutputStream fs = new
FileOutputStream(”MyClass.ser”); A instance of
ObjectOutputStream os = new MyClass and
ObjectOutputStream(fs); an instance
os.writeObject(mc); os.close(); An exception An instance of Tree are
} catch (Exception ex) { ex.printStackTrace(); } Compilation is thrown at of MyClass is both
}} fails runtime serialized serialized
397 Consider the following code and choose the
correct option:
class std implements Serializable{
int call; std(int c){call=c;}
int getCall(){return call;}
}
public class Test{
public static void main(String[] args) throws
IOException {
File file=new File("d:/std.txt");
FileOutputStream fos=new
FileOutputStream(file);
ObjectOutputStream oos=new
ObjectOutputStream(fos); the state of
std s1=new std(10); the state of the object s1
oos.writeObject(s1); the object s1 Compiles but will not be
oos.close(); will be store Compilation error at run store to the
}} to file std.txt error time file.
398 Consider the following code and choose the
correct option:
public class Test {
public static void main(String[] args) throws
IOException {
File file=new File("D:/jlist.lst");
byte buffer[]=new byte[(int)file.length()+1]; reads data reads data
FileInputStream fis=new from file one from file
FileInputStream(file); byte at a time named jlist.lst
int ch=0; and display it in byte form Compiles but
while((ch=fis.read())!=-1){ on the Compilation and ascii error at
System.out.print(ch); } }} console. error value runtime
399 Consider the following code and choose the
correct option:
public class Test {
public static void main(String[] args) throws
IOException {
File file=new File("D:/jlist.lst"); reads data
byte buffer[]=new byte[(int)file.length()+1]; reads data from file
FileInputStream fis=new from file one named jlist.lst
FileInputStream(file); byte at a time in byte form
int ch=0; and display it and display Compiles but
while((ch=fis.read())!=-1){ on the Compilation garbage error at
System.out.print((char)ch); } }} console. error value runtime
400 Consider the following code and choose the
correct option:
public class Test { Compiles and
public static void main(String[] args) { creates Compiles but executes but
File file=new File("d:/prj/lib"); directory Compilation error at run directory is
file.mkdirs();}} d:/prj/lib error time not created
401 Consider the following code and choose the
correct option:
public class Test {
public static void main(String[] args) throws
IOException {
String data="Confidential info";
byte buffer[]=data.getBytes();
FileOutputStream fos=new writes data to
FileOutputStream("d:/temp"); writes data to the file in Compiles but
for(byte d : buffer){ file in byte Compilation character error at
fos.write(d); } }} form. error form. runtime
402

Given :
import java.io.*;
public class ReadingFor {
public static void main(String[] args) {
String s;
try {
FileReader fr = new FileReader("myfile.txt");
BufferedReader br = new BufferedReader(fr);
while((s = br.readLine()) != null)
System.out.println(s);
br.flush();
} catch (IOException e) {
System.out.println("io error"); }
}
}
And given that myfile.txt contains the following
two lines of data:
ab
cd Compilation
What is the result? ab Error ab cd abcd
403 Consider the following code and choose the
correct option:
class std{
int call; std(int c){call=c;}
int getCall(){return call;}
}
public class Test{
public static void main(String[] args) throws
IOException {
File file=new File("d:/std.txt");
FileOutputStream fos=new
FileOutputStream(file);
ObjectOutputStream oos=new
ObjectOutputStream(fos); the state of
std s1=new std(10); the state of the object s1
oos.writeObject(s1); the object s1 Compiles but will not be
oos.close(); will be store Compilation error at run store to the
}} to file std.txt error time file.
404 Consider the following code and choose the
correct option:
public class Test {
public static void main(String[] args) {
File file=new File("D:/jlist.lst");
byte buffer[]=new byte[(int)file.length()+1]; reads data
FileInputStream fis=new reads data from file
FileInputStream(file); from file named jlist.lst
fis.read(buffer); named jlist.lst in byte form
System.out.println(buffer); in byte form and display Compiles but
} and display it Compilation garbage error at
} on console. error value runtime
405 Consider the following code and choose the
correct option:
public class Test {
public static void main(String[] args) throws
IOException { reads data
File file=new File("D:/jlist.lst"); reads data from file
byte buffer[]=new byte[(int)file.length()+1]; from file named jlist.lst
FileInputStream fis=new named jlist.lst in byte form
FileInputStream(file); in byte form and display Compiles but
fis.read(buffer); and display it Compilation
garbage error at
System.out.println(new String(buffer)); }} on console. error value runtime
406 throws a
What happens when the constructor for throws a throws a ArrayIndexOu
FileInputStream fails to open a file for DataFormatE FileNotFound tOfBoundsEx
reading? xception Exception ception returns null
407 Consider the following code and choose the
correct option: creates Compiles and
public class Test { directories executes but
public static void main(String[] args) { names prj Compiles but directories
File file=new File("d:/prj,d:/lib"); and lib in d: Compilation error at run are not
file.mkdirs();}} drive error time created
408 Consider the following code and choose the
correct output:
public class Person{
public void talk(){ System.out.print("I am a
Person "); }
}
public class Student extends Person {
public void talk(){ System.out.print("I am a
Student "); }
}
what is the result of this piece of code:
public class Test{
public static void main(String args[]){
Person p = new Student();
p.talk(); I am a I am a
} I am a I am a Person I am Student I am
} Person Student a Student a Person
409 Which of these are two legal ways of
accessing a File named "file.tst" for reading.
Select the correct option:
A)FileReader fr = new FileReader("file.tst");
B)FileInputStream fr = new
FileInputStream("file.tst");
C)InputStreamReader isr = new
InputStreamReader(fr, "UTF8");
D)FileReader fr = new FileReader("file.tst",
"UTF8"); A,D B,C C,D A,B
410 What is the DataOutputStream method that
writes double precision floating point values to
a stream? writeBytes() writeFloat() write() writeDouble()
411 Consider the following code and choose the
correct option:
public class Test{
public static void main(String[] args) {
File dir = new File("dir"); The file
dir.mkdir(); The file The file system has a
File f1 = new File(dir, "f1.txt"); try { The file system has a system has a directory
f1.createNewFile(); } catch (IOException e) { system has a new empty directory named
;} new empty directory named dir, newDir,
File newDir = new File("newDir"); directory named containing a containing a
dir.renameTo(newDir);} } named dir newDir file f1.txt file f1.txt
412
Consider the following code and choose the
correct option:
public class Test {
public static void main(String[] args) throws
IOException {
File file=new File("d:/data");
byte buffer[]=new byte[(int)file.length()+1];
FileInputStream fis=new Compiles and
FileInputStream(file); Transfer runs but
fis.read(buffer); content of file Compiles but content not
FileWriter fw=new FileWriter("d:/temp.txt"); data to the Compilation error at transferred to
fw.write(new String(buffer));}} temp.txt error runtime the temp.txt
413
import java.io.EOFException;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
public class MoreEndings {
public static void main(String[] args) {
try {
FileInputStream fis = new
FileInputStream("seq.txt");
InputStreamReader isr = new
InputStreamReader(fis);
int i = isr.read();
while (i != -1) {
System.out.print((char)i + "|");
i = isr.read();
}
} catch (FileNotFoundException fnf) {
System.out.println("File not found");
} catch (EOFException eofe) {
System.out.println("End of stream");
} catch (IOException ioe) {
System.out.println("Input error");
} The program
} will not
} compile The program
Assume that the file "seq.txt" exists in the because a The program The program will compile,
current directory, has the required certain will compile will compile print H|e|l|l|o|,
access permissions, and contains the string unchecked and print and print and then
"Hello". exception is H|e|l|l|o|Input H|e|l|l|o|End terminate
Which statement about the program is true? not caught. error. of stream. normally.
414 Consider the following code and choose the
correct option:
public class Test{ Skip the first
public static void main(String[] args) throws seven
IOException { characters
File file = new File("d:/temp.txt"); and then
FileReader reader=new FileReader(file); starts reading
reader.skip(7); int ch; file and Compiles and Compiles but
while((ch=reader.read())!=-1){ display it on Compilation runs without error at
System.out.print((char)ch); } }} console error output runtime
415 The file is
modified from
A file is readable but not writable on the file A being
system of the host platform. What will SecurityExce The boolean The boolean unwritable to
be the result of calling the method canWrite() ption is value false is value true is being
on a File object representing this file? thrown returned returned writable.
416 void add(int void add(int void add(int
x,int y) char char add(float x,int y) char x,int y) void
Which of following set of functions are add(int x,int x) char add(char sum(double
example of method overloading y) add(float y) x,char y) x,double y)
417
Efficient avoiding
utilization of Code method name
What is the advantage of runtime memory at flexibility at confusion at
polymorphism? runtime Code reuse runtime runtime
418
Which of the following is an example of IS A Microprocess
relationship? Ford - Car or - Computer Tea -Cup Driver -Car
419 Which of the following is not a valid relation Segmentatio
between classes? Inheritance n Instantiation Composition
420 Which of the following is not an attribute of
object? State Behaviour Inheritance Identity
QuestionText Choice1 Choice2 Choice3 Choice4 Choice5 Grade1 Grade2 Grade3 Grade4 Grade5 AnswerDescription
QuestionMedia AnswerMedia Author Reviewer Is Numeric

Carefully read the question & answer accordingly: int


i;
void increment (int i)
{
i++;
}

int main()
{
for( i = 0; i < 10; increment( i ) )
{
}
printf("i=%d\n", i);
return 0;
}

What is the output of given code snippet? loop will go infinite state. i=10 i=9 i=11 1 0 0 0 TEXT TEXT

Carefully read the question & answer accordingly:


void main ()
{
int i, j=5;
i=5>++j<3;
if(!i)
printf ("%+d" , !i);
}
What is the output of given code snippet? 1 compile time error
None of these options. 0 0 1 0 TEXT TEXT

Carefully read the question and answer accordingly. int


main() { int num,factorial; printf('Enter a
number.\n'); scanf('%d',
&num); factorial=1; while
(num>0) { ------------------ } printf
('Factorial=%d',factorial); getch(); factorial=fact factorial=fact factorial=fact
return 0; } identify a correct option factorial=factorial+num; orial*num; -- orial*num; orial+num; --
which will give the factorial number for given input. ++num; num; ++num; num; 0 1 0 0 TEXT TEXT

Carefully read the question & answer accordingly:


void main()
{
int i = 0;
for (i=0; i<20; i++)
{
switch(i)
{
case 0 : i += 4;
case 1 : i += 1;
case 5 : i += 7;
default : i += 4;
break;
}
printf("%d ", i);
}
} 4 1 4 4 4 7 and i=6 to 19 it
What is the output of given code snippet? will print 4 12 17 22 4 11 16 21 16 21 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly:
Select the Missing code from the below code
snippet. for(i=1;i<=n;i++) { printf
('Enter num %d: ',i); scanf('%f',
&num); if(num<0. continue
0) -------------------- } jump: if(i! jump; break;
=1) average=sum/(i-1); printf goto jump; sum=sum+nu sum=sum+nu
('Average: %2f',average); sum=sum+num; Exit; m; m; 1 0 0 0 TEXT TEXT

Carefully read the question & answer accordingly:


int main()
{
int n;
for (n = 9; n!=0; n--) Error
printf("\t%d", n--); "negative
return -1; value can not
} return to
What is the output of given code snippet? 987654321 main()" Inifinite loop 97531 0 0 1 0 TEXT TEXT

Carefully read the question & answer accordingly: int


inc_value(int a)
{
a=20;
return 5+ (++a);
}
void main()
{
int a=10,c;
while (a>0)
{
c=inc_value(a);
printf("%d",c);
a-=10;
}
} None of
What is the output of given code snippet? Infinite 25 16 26 these options 0 0 0 1 0 TEXT TEXT

Carefully read the question & answer accordingly:


What is your observation on the below code?
int main()
{ int i,num,item,product=1;
for(i=1,item=1;i<=4;++i)
{
printf("Enter num%d:",i);
scanf("%d",&i);
if(num==0) continue;
product*=num; Next iteration
} will be Infinite Loop Loop will be
printf("product=%d",product); considered when 0 is terminated
return 0; Loop will not be executed when zero is given None of the when zero is
} more than 4 times given continuously listed options given 0.5 0.5 0 0 0 TEXT TEXT
What is the output of the below code? void main
() { int x = 4, y = 0, z ; while ( x >= 0 ) { if
( x == y ) break ; else printf
('\n%d %d', x, y ) ; x-- ; y++ ; } getch();
} 4032 4031 4030 4033 0 1 0 0 TEXT TEXT

Carefully read the question and answer accordingly.


What is the output of the below program?

void main()
{
int d,i,j;
d=0;
for(i=1; i<5 ; i++)
for(j=1; j<5 ; j++)
if(((i+j)%3) == 0)
d= d+1;
printf("%d" , d);
getch();
} 10 13 5 20 0 0 1 0 TEXT TEXT

Carefully read the question & answer accordingly:


void main()
{
int i = 0;
for(i=0;i<++i;);
switch (i)
{
case '0': printf("case1");
break;
case '1': printf("Case2");
break;
default: printf("Default Case");
}
} loop will go None of
What is the output of given code snippet? case2 case1 Default Case infinite state. these option. 0 0 1 0 0 TEXT TEXT

Carefully read the question & answer accordingly:


void main() {
int counter = 5,number = 10;
do
{
number/= counter;
} while(counter--);
printf ("%d", number);
} Garbage
What is the output of the given code snippet? Divide error value O 2 1 0 0 0 TEXT TEXT
Carefully read the question & answer accordingly:
void main()
{
int list[6],j;
for(j = 0; j < 6; j++)
{
list[j] = 3 * j + 4;
if (j % 3 == 0)
{
list[j] = list[j] - 2;
}
}
for(j=0;j<6;j++)
printf("\t%d",list[j]); None of
} 10 15 18 19 these 2 7 10 11 16
What is the output of given code snippet? 4 7 10 11 16 19 24 27 options. 19 0 0 0 1 TEXT TEXT

Carefully read the question & answer accordingly:


void main()
{
int choice = 20, arr[] = {10, 20, 30};
switch (choice)
{
case arr[0]: printf("Morning");
case arr[1]: printf("Evening");
case arr[2]: printf("Night");
default:printf("After Noon");
}
} Compile-time
what is the output of given code snippet? Night Morning After Noon Evening error 0 0 0 1 TEXT TEXT

Carefully read the question and answer accordingly:


void main( ) { int i, j ; for ( i = 1;i<= 2 ;
i++ ) { for ( j = 1 ; j <= 2 ; j++ ) { if
( i == j ) continue
; printf ( '\n%d %d\n', i, j )
; } } } What is the output of
above program? 1221 1111 2122 1212 1 0 0 0 TEXT TEXT

Carefully read the question & answer accordingly:


void main( )
{ int i, j ;
clrscr();
for (i=10;i<12; i++ )
{
for (j=10;j<12;j++)
{
if ( i == j )
continue ;
printf ( " %d %d", i, j ) ;
}
}
getch();
} 10 11 11 10
what is the output of above program? 10 11 11 10 12 11 10 12 11 12 10 11 11 12 1 0 0 0 TEXT TEXT

Carefully read the question & answer accordingly:


What is the output of the below code

void main( )
{
int i = 1, j = 1 ;
for ( ; ; )
{
if ( i > 5 )
break ;
else
j += i ;
printf ( "%d ", j ) ;
i += j ;
} Compile
} Run time error 25 24 Time Error 0 1 0 0 TEXT TEXT

Carefully read the question & answer accordingly:


void main()
{
int i = 3;
switch(i)
{
printf("All The Best");
case 1:
printf("Case1");
break;
case 2:
printf("Case2");
break;
default:
printf("default Case");
}
}
None of Compile-time
What is the output of given code snippet? Default Case these option All The Best error 0 1 0 0 TEXT TEXT

Carefully read the question & answer accordingly:


What is your observation on the below code snippet?
switch(operator)
{
case '+':
printf("num1+num2=%.2f",num1+num2);
getch();
break;
case '-':
printf("num1-num2=%.2f",num1-num2);
getch();
Default block Default block
default: will also be Run time Compile-time will also be
printf("Operator is not correct"); executed error -Break error while executed
getch(); when the is missing in executing when the
break; Compile-time error while operator "+" case with "-" operator "-"
} executing with "+" Operator given statement. Operator given 0 0 0 0 1 TEXT TEXT

Carefully read the question & answer accordingly:


What is the output of below code?
int main()
{
int a = 60;
printf("\n%d",a << 1);
} 240 120 480 60 0 1 0 0 TEXT TEXT

Carefully read the question & answer accordingly:


void main()
{
FILE *fp;
char str[20];
fp=fopen("MSG.txt","a");
fputs("You're alive.Do something!",fp);
fclose(fp);
fp=fopen("MSG.txt","r");
fgets(str,10,fp);
printf("%s",str); None of
} these ve. Do
What is the output of above code snippet? You're ali options. something! You're al 0 0 0 1 TEXT TEXT
file_pointer.
close()
method is
used to fgets(); None of the
Carefully read the question & answer accordingly: closing the returns null listed options
Choose the correct option? w+b and wb+ are same files. on error are true 1 0 0 0 TEXT TEXT

Carefully read the question & answer accordingly:


void main()
{
FILE *fp;
char str[20];
fp=fopen("abc.txt","w");
fputs("i am a boy\r\n",fp);
fclose(fp);
fp=fopen("abc.txt","r");
fgets(str,10,fp);
printf("%s",str); I am a boy and cursor will
} go to new line. I am a boy\r\n I am a boy I am a bo 0 0 0 1 TEXT TEXT
Carefully read the question & answer accordingly:
Which of the following operations can be performed on
the file "MyFile.txt" using the below code?

FILE *fp; Read and


fp = fopen("MyFile.txt", "r+"); Archive Read Append Write Write 0 0 0 0 1 TEXT TEXT
Carefully read the question & answer accordingly:
Which of the following function can be used to
terminate the main function from another function
safely? All Of the Options return(expr); abort(); exit(expr); 0 0 0 1 TEXT TEXT

Carefully read the question & answer accordingly:


What is the output of below code:

void main()
{
FILE *fp;
clrscr();
fp=fopen("XYZ.doc","w");
fputs("Hello",fp); XYZ file will
fclose(fp); Compile-time XYZ file will contain
} None of these. error be black "Hello" 0 0 0 1 TEXT TEXT
Carefully read the question & answer accordingly: The
Content of a file will be lost if it is opened in : w+ mode w mode a mode c mode 1 0 0 0 TEXT TEXT

Carefully read the question & answer accordingly:


void main()
{
FILE *fp;
char str[2];
fp=fopen("Believe.txt","w");
fputs("you can do it.",fp);
fp=fopen("Believe.txt","r");
fgets(str,7,fp); fp=fopen
printf("%s",str); ("Believe. fgets should
} txt","r"); need fclose(fp); be replaced
What change is required to read accurate values from char str[2]; size need to be to be need to be with fgets(str,
the file? increased removed. used. fp); 0 0 1 0 TEXT TEXT

Carefully read the question & answer accordingly:


void main()
{
char str[2];
FILE *fp;
fp=fopen("Life.txt","r");
fgets(str,4,fp);
printf("%d",str);
}
//Life.txt contains:
Life is beautiful.
What is the output of above code snippet? Lif L Li Life 1 0 0 0 TEXT TEXT
Carefully read the question & answer accordingly:
The Function sprintf works like printf but operates on none of the
the string pointer listed options data in a file 1 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
Which of the following data structure is linear data None of the
structure? Graphs Tree Arrays listed options 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
The way a card game player arranges his cards as he
picks them up one by one is an example of : Bubble Sort Merge sort selection Sort insertion sort 0 0 0 1 TEXT TEXT

A tree which A tree


does not with&nbsp;
have any n&nbsp;
node other nodes has
A tree which does not have than root exactly&nbsp
Carefully read the question and answer accordingly. any node other than root node is called ;n branches None of the
Which of the following options are correct? node has depth of zero. a null tree or degree. options. 0.5 0.5 0 0 TEXT TEXT

An arrow coming from one


symbol and ending at Represents
another symbol represents Represents Predefined Represents
Carefully read the question and answer accordingly. that control passes to the Input / Output Process Stored data
Where do we use the Arrow in the flowchart? symbol the arrow points to. symbol symbol symbol 1 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
One of the best application of Stack is Breadth First Search Recursion Array Radix sort 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
The if ... else keyword in a pseudocode is similar to the
_____________ symbol in a flowchart. Subroutine Annotation Decision Process Procedure 0 0 1 0 0 TEXT TEXT

A serial
search
continues
searching
element by A serial
element search is
either until a useful when
A serial match is the amount of
For a serial search to work search found or until data that
the data in the array must begins with the end of must be
Carefully read the question and answer accordingly. not be alphabetic or the first Array array is searched is
Which of the options is false : numeric order. element found. large. 0 0 0 1 TEXT TEXT

Carefully read the question and answer accordingly. Push-down None of the
Which of the following name does not relate to stacks? LIFO list lists options. FIFO lists 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
The operation of processing each element in the list is
known as Sorting Inserting Merging Traversal 0 0 0 1 TEXT TEXT
Identify the Specify the
base of Direct the problem
Carefully read the question & answer accordingly: number output to a completely
Algorithm and Flow chart help us to Know the memory capacity system printer and clearly 0 0 0 1 TEXT TEXT

Carefully read the question & answer accordingly: int


main()
{
int a=0,b=0;
display(a,b);
getch();
return 0;
}
int display(int a, int b)
{
a=(b=75)+9;
printf("%d%d",a,b);
return 0;
}
What is the output of above program? Run Time Error 75,84 84,75 84,84 0 0 1 0 TEXT TEXT

Carefully read the question & answer accordingly:


Find the output of the below program

void fun();
int i = 10;
void main()
{
int i =20;
printf("%d",i);
i = 30;
fun();
}
void fun()
{
printf("%d",i);
} 20 30 10 30 20 20 20 10 0 0 0 1 TEXT TEXT

Carefully read the question & answer accordingly:


What will be output if you compile and execute the
following c code?
#define x 9+2
void main()
{
int o;
o=x*x;
printf("%d",o);
} Compile error 133 29 343 0 0 1 0 TEXT TEXT
Carefully read the question & answer accordingly: The
keyword used to transfer control from a function back
to the calling function is goto switch return goback 0 0 1 0 TEXT TEXT
As a datatype
of a function
that does not
returns any
value to its
Carefully read the question & answer accordingly: calling as the name in an
void can be used All of the listed options. environment. of a variable expression 0 1 0 0 TEXT TEXT

Carefully read the question & answer accordingly:


What will be the output if you compile and execute the
following c code?
#define x 52+1
void main()
{
int i;
i=x+x;
printf("%d",i);
} 106 12 18 10 1 0 0 0 TEXT TEXT

Carefully read the question & answer accordingly:


What are your observations in the below code? float Datatype of
average(float a[],n) { int i; float avg, sum=0.0; for(i=1; This code will array a[]
i<=n;i++) { printf("%f",a[i]); sum+=a[i]; } avg =(sum/n); This code will throw an be executed should not be Data Type of
printf("average= %f",avg); return avg; } Error properly given n is missing 0.5 0 0 0.5 TEXT TEXT

Carefully read the question & answer accordingly:


int printvalues(float);
void main()
{
float f=2.5;
float value;
value = printvalues(f);
printf("%f",value);
}
int printvalues(float f)
{
switch(f)
{
case 2.3 :
printf("Value is 2.3");
case 2.5 :
printf("Value is 2.5");
default :
printf("invalid case");
} This will
} None of the Value is 2.5, produce
What will be the output of above program? Value is 2.5 listed options invalid case error. 0 0 0 1 TEXT TEXT
Excessive
Carefully read the question & answer accordingly: Call by use of global
Features for accessing a variable through its address A function can return more reference can All of the variable can
is desirable because than one value. be simulated. options. be avoided 0 0 1 0 TEXT TEXT
Carefully read the question & answer accordingly: Any One section to get input One display One Looping
program must contain atleast : data block. One function constructs 0 0 1 0 TEXT TEXT

No need to
worry about
Does not the allocation
store in Automatic and de-
Carefully read the question & answer accordingly: contiguous array bounds allocation of
Which is true about array ? None of the given options locations checking arrays 1 0 0 0 TEXT TEXT
Carefully read the question & answer accordingly:
Which of the following function is more appropriate for
reading in a multi-word string? printf(); puts(); scanf(); gets(); 0 0 0 1 TEXT TEXT

Carefully read the question and answer accordingly.


What is the output in the below code snippet? void
main() { int twod[3][3]; int i,
j; clrscr(); for(i=0; i<3;
i++) for(j=0; j<3; j++) twod[i][j] =
i*j; for (i=0; i<3;
i++) { for (j=0; j<3;
j++) printf('%d ', twod[i] 1110110 0000120 1110120
[j]); printf('\n'); } } 0001 24 24 24 0 0 1 0 TEXT TEXT
Carefully read the question & answer accordingly: The array
What will happen if in a program, you assign a value to The program may crash if The compiler The element size would
an array element whose subscript exceeds the size of some important data gets would report will be set to appropriately
array? overwritten. an error. 0. grow. 1 0 0 0 TEXT TEXT

Carefully read the question & answer accordingly:


What will be the output of following program?
void main()
{
float b=7.4;
printf("%d",(int)b); None of the
} 9 listed options 8 7 74 0 0 0 1 0 TEXT TEXT

Carefully read the question & answer accordingly:

void main() {
int arr[][3]={{1,2},{3,4,5},{5,4}};
printf("%d %d %d",arr[0][2],arr[1][2],arr[2][1]);
getch();
}

What is the output of the given code snippet? Compilation error Runtime error 0,5,5 0,5,4 2,4, 5 0 0 0 1 0 TEXT TEXT
Address of
Carefully read the question & answer accordingly: If the last
you pass an array as an argument to a function, what Base address First element element of
actually gets passed? Value of elements in array of the array of the array array 0 1 0 0 TEXT TEXT

Carefully read the question & answer accordingly:


What will be the output when you execute following
code?
void main()
{
char arr[11]="Welcome To Programming";
printf("%s",arr);
} None of the Welcome To Compilation
Choose that apply: Welcome To given options P Welcome error 0 0 0 0 1 TEXT TEXT
Initialization
Carefully read the question & answer accordingly: is a part of It is a formal It is
Size of the array need not be specified. When? All of the options. definition parameter declaration 0 0.5 0.5 0 TEXT TEXT

Carefully read the question & answer accordingly:


What will be output of the below program?

int main()
{
char str[] = "Programming";

printf("%s ",&str[2]);
printf("%s ",str);
printf("%s ",&str); Program
Compiled ogramming Programming
return(0); ogramming Programming < with Syntax Programming ogramming
} Garbage Value > Errors Programming Programming 0 0 1 0 TEXT TEXT

Carefully read the question and answer accordingly.


The term ____ means a separate physical computer None of the
system that host a part of the application architecture. Layer tier listed options both 0 1 0 0 TEXT TEXT
Electronic Extensible
Carefully read the question and answer accordingly. Data Markup
Which of the applications has most increased business None of the Interchange Language All the listed
usage of the Internet? World Wide Web (WWW) listed options (EDI) (XML) options 1 0 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
Which of the following DO NOT allow multiple Gateways Firewalls
applications to participate in a transaction? Routers Switches Net Beans. 0 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly. In
the Client-Server architecture, the component that
makes a service request is Network Process Server Protocol Client 0 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly. Complex
Choose the major disadvantages of a Client Server None of the All the listed Traffic business
architecture Lack of robustness listed options options congestion logic involved 0.5 0 0 0.5 0 TEXT TEXT
Carefully read the question and answer accordingly. Database
Every computer on the Internet that contains a Web Server None of the Web Server File Server
site must have a _________. Business logic program program listed options program program 0 0 0 1 0 TEXT TEXT
Divided
between
Carefully read the question and answer accordingly. In client and The
3-tier client/server applications, the business logic lies server Database
at __________. The client Firewall Middle Tier alternatively Server 0 0 1 0 0 TEXT TEXT
Connects to
several Interacts with
Carefully read the question and answer accordingly. servers at the end user with Initiates a Processes
Which of these are the functionalities of a Client All the listed options same time GUI request requests 0 0.33 0.33 0.33 0 TEXT TEXT
Carefully read the question and answer accordingly.
Call-free charges across the Internet between PCs and Really Simple Syndication IM (Instant Voice Over None of the
phone systems is an application of: (RSS). Messaging). IP (VOIP). IPTV listed options 0 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
Choose one from the following which is not a possible Database Transaction
kind of server. Time Server Server Server File Server 1 0 0 0 TEXT TEXT

Better
Sharing of It is Easy to
critical updated and
database modernise
resources Faster system, both
and other Response hardware and
application and flexibility software as
softwares to changing the Reduce
among environment companies operation and
Carefully read the question and answer accordingly. clients of business evolved and maintenance
What are the benefits of employing Client-Server throughout world has new cost to a
Computing in business ? All the listed options the network. outside. requirements. large extent. 1 0 0 0 0 TEXT TEXT
Accepts
connections
Waits for Interacts with from large
Carefully read the question and answer accordingly. Processes and serves client end user with All the listed number of
Which of these are the functionalities of a Server client requests requests GUI options clients 0.33 0.33 0 0 0.33 TEXT TEXT

uses more
than three uses three
sets of sets of
computers in computers in
which the which the
client is clients are
responsible responsible
forpresentatio for
n, one set of presentimentl
servers is ogic, one set
responsible of servers are
for data responsible
access logic for
and data application
storage,and logic, and
uses only two sets of application one set of
computers in which the logic is serversare
clients are responsible for puts less load spread responsible
theapplication and on a network across two or for the data
Carefully read the question and answer accordingly. presentation logic, and the than a two- more access logic
An N-tiered architecture _____. choose all answers servers are responsible for tiered different sets and data
applicable the data architecture of servers storage 0 0.5 0.5 0 TEXT TEXT
Carefully read the question and answer accordingly. Business
The database server holds the following ________ and Database Management Database All the given logic of data
______. systems instances options access 0.5 0.5 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
The computer that accepts, prioritizes, and processes printer file
print jobs is known as the print server print client mainframe server. 1 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly. In
3-tier computing, the request/response protocol POP3 NNTP SMTP
between the clients and web servers is HTTP MOM 1 0 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
One major disadvantage of an n-tiered client-server
architecture is that it is much more Difficult to program
and test software false true 0 1 TEXT TEXT
Carefully read the question and answer accordingly. A
company ___________________ can be used to None of the
provide shared content for staff only intranet listed options extranet opranet Internet 1 0 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly. In
the client/server architecture, the component that
processes the request and sends the response Network Server
is_______________ Client O.S. Protocol 0 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly. An
advantage of the three-tier architecture over the two- Better Easier All the listed
tier architecture is: Better control over the data performance maintenance options 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
Choose the correct option from the list POWER(5*6) POWER(5,6) POWER(5#6) POWER(5^6) 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
Which excel function is used to calculate the Rates of All of the
Return? Statistical Mathematical listed options Financial Logical 0 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly. All the listed Group of Group of
Workspace denotes _____________. Group of worksheets options rows workbooks 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly. All the listed
Choose an example of a function from the given list C1+C5 ADD(C1:C5) options AVG(C1:C5) C1:C5 0 0 0 1 0 TEXT TEXT

Single Click Single Click


on the on the
Worksheet Double click Worksheet
tab by on the tab by
holding CTRL Worksheet holding
Carefully read the question and answer accordingly. key and type tab and type SHIFT key
Choose an action from the given list to rename a Worksheet cannot be the new the new and type the
worksheet renamed name name new name 0 0 1 0 TEXT TEXT
Option 2 ---
Carefully read the question and answer accordingly. Option 3 --- option 1 --- SUM(G1:G9,
Choose the correct syntax of the SUM function in excel All the listed options SUM(G1:H9) SUM(G1,H1) H1:H9) Both 2 and 3 1 0 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly. None of the
Choose an example of a formula from the given list G1:G2 SUM(G1+G2) ADD(G1:G2) G1+G2 listed options 0 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
What function in excel arranges row data in a column
and column data in a row ? Rows Columns Transpose Index 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
Which chart is used to show the proportions of how one All the given
or more data elements relate to one other? Column Chart Pie chart options Line Chart 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly. Function Formula
Choose the types of conditions on which conditional Cell value based based All the listed based
formatting can be applied conditions conditions options conditions 0.5 0 0 0.5 TEXT TEXT
Carefully read the question and answer accordingly.
Which excel function is used to display the current date
in a cell? now() today() time() date() 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
Choose the function to find out the highest number MAX(C1: MAX(C1, HIGH(C1:
among the 15 values entered in the column C HIGH(C1,C15) C15) C15) C15) 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
How do you reference the cell D7 on Sheet5 from
Sheet2? Sheet5!D7 Sheet5.D7 Sheet2.D7 Sheet2!D7 1 0 0 0 TEXT TEXT
Multiplication, Subtraction, Exponentiatio
Exponentiatio Comparison, n,
Carefully read the question and answer accordingly. Comparison,Subtraction, n, Multiplication, Multiplication,
Choose the Order of operation in which Excel performs Multiplication, Subtraction, Exponentiatio Subtraction,
calculations in a formula Exponentiation Comparison n Comparison 0 1 0 0 TEXT TEXT

The data in
the table
should be The data in
sorted in the table
ascending need not be
VLOOKUP order, while sorted, while
Carefully read the question and answer accordingly. VLOOKUP function can be stands for using using
Choose the correct statements related to VLOOKUP used on a series of data in Vertical VLOOKUP VLOOKUP
function single column LOOKUP function function 0 0.5 0.5 0 TEXT TEXT
Option 1 ---
Option 2 --- Option 3 --- Text, Values
Carefully read the question and answer accordingly. Both Options Text, Values Text, Values and
Choose the types of data used in Excel. Both Options 1 and 2 1 and 3 and Formulas and Charts Functions 1 0 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
Excel stores dates and times as numbers, which
enables its usage as functions and formulas. State
True or False. false true 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
Which is the key used to select multiple non-adjacent None of the CTRL+Shift
cells in a worksheet, while clicking on them Shift Key CTRL Key ALT key listed options Key 0 1 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly. Option 1 --- Option 3 --- Option 2 ---
Choose the correct syntax of the AVERAGE function in All the listed AVERAGE AVERAGE AVERAGE
excel Both Options 2 and 3 options (G1,H1) (G1:G9,H1: (G1:H9) 0 1 0 0 0 TEXT TEXT
H9)
A column is
not wide
Carefully read the question and answer accordingly. A Function enough to A value of the
What does the Error Value #NAME? specify in an name is display the name is
excel? All the listed options misspelled name misspelled 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
Choose the option to fit long addresses of multiple lines Text Wrap All the listed Shrink to Fit
in a single cell? Merge option option options option 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly. Value_when_ None of the Value_if_fals
Which of these is not an argument of the IF function? Logical_test false listed options Value_if_true e 0 1 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly. only options option 1 --- option 2 --- option 3 ---
What are the types of charts, excel can produce? All the listed options 1 and 3 Bar charts Line graphs Pie charts 1 0 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly. Two columns Two columns Two columns
What is the resultant of the below action? will be will be will be
Select both the columns M and N in a worksheet and Two columns will be inserted after inserted after inserted after
choose -> Insert -> Insert Sheet Columns inserted after column L column M column O column N 1 0 0 0 TEXT TEXT
It sums two
cells with It sums cells
Carefully read the question and answer accordingly. It counts cells with multiple multiple All the listed with values or
What is the function of COUNTIFS? criteria arguments options labels 1 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
Choose the Validation type to be given, to prevent All the listed
duplicate entries of Invoice data in a range of cells Whole number options Custom Decimal Date 0 0 1 0 0 TEXT TEXT
SUMIF
(Sum_range,
Criteria_rang
SUMIF e1,Criteria1,
(Range, Criteria_rang
Carefully read the question and answer accordingly. SUMIF(Number1, None of the Criteria, Sum e2,Criteria2,
Choose the correct syntax of the SUMIF function Number2…) listed options Range) …) 0 0 1 0 TEXT TEXT
Cells
Carefully read the question and answer accordingly. Cells K14 inbetween None of the
K14:K28 Indicates values of : Cells K14 through K28 and K28 only K15 and K27 listed options 1 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
The method used to get data from a different
worksheet is called as _________________. Accessing Verifying Referencing Functioning 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
What is the resultant of the below action? Two rows will Two rows will Two rows will
Select both the rows 3 and 4 in a worksheet and Two rows will be inserted be inserted be inserted be inserted
choose -> Insert -> Insert Sheet Rows after Row 2 after Row 5 after Row 4 after Row 3 1 0 0 0 TEXT TEXT
<a url="http: <a href="http:
//www. //www.
example. example.
Carefully read the question and answer accordingly. com" com"
What is the correct HTML syntax for creating a >example</a >example</a
hyperlink? <a name="">tA</a> > > <a>B</a> 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
How can you make a list that lists the items with
numbers? <ul> <ol> <list> <dl> 1 0 0 0 TEXT TEXT
Heading Heading Heading
Carefully read the question and answer accordingly. information is information information is
What does the Web browser assume while using a Heading information is to to appear on has a shown as a
heading tag in a html document? appear in bold letters its own line hyperlink size six 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly. If
you don’t want the frame windows to be resizeable,
simply add what to the lines ? None of the listed options dontresize noresize save 0 0 1 0 TEXT TEXT
<embed <embed <embed
sound="song. src="song. audio="song.
mid" width=" mid" width=" mid" width="
Carefully read the question and answer accordingly. <embed music="song.mid" 500" height=" 500" height=" 500" height="
Choose the right syntax to embed "audio files" in HTML width="500" height="10" > 10" > 10" > 10" > 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
Which is the correct syntax to create an Arabic numeric
list <li type="1"> <ol type="1"> <ul type="1"> <il type="1"> 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
When creating a Web document, what format is used
to express an image's height and width? Dots per inch Pixels Inches Centimeters 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly. None of the
how many "browser safe colors"are there? 216 16 Million 256 given options 0 0 1 0 TEXT TEXT

<html><body
><h1 style=" <html><body <html><body
font- ><h1 style=" ><h1 style="
family=verda font-family: font-family:
na;">A verdana;">A verdana;">A
heading</h1> heading</h1> heading</h1>
<p style=" <p style=" <p style="
<html><body><h1 style:" font-family: font-family: font-family:
font-family:verdana;">A arial;color: arial;color: arial,color:
heading</h1><p style:" red;font-size: red;font-size: red;font-size:
font-family:arial;color:red; 20px;">A 20px;">A 20px">A
font-size:20px;">A paragraph. paragraph. paragraph.
Carefully read the question and answer accordingly. paragraph. </p></body> </p></body> </p></body>
Identify the correct code for font,color and size </p></body></html> </html> </html> </html> 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly. Refresh your Redirect to a
What is the REFRESH meta tag used for in html? None of the listed options content new domain rewrite url 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
Address of the HTML links are specified in which
attribute? hr br href align 0 0 1 0 TEXT TEXT
It connects
your web site It hides
It specifies formatting and to an programming
Carefully read the question and answer accordingly. layout instructions for your None of the operating instructions
What does a HTML tag do? web page. listed options environment. from view. 1 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly. In
which color is Anchor displayed by default? green blue pink red 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
What is the another way to make text bold besides None of the
<b>? All the listed options <strong> listed options <fat> <dark> 0 1 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly. 1x1 pixel
Rather than using Hspace and Vspace you can use height and transparent
which of the following to add spacing to your image ? None of the listed options width image align=+2 0 0 1 0 TEXT TEXT
<a href="
Carefully read the question and answer accordingly. <mail>@b</ mailto:a@b. <mail href="
How can you create an e-mail link in html? <a href="a@b"> mail> com"> a@b"> 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
How many types of lists are there in HTML 3 2 1 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
Which of the following is used to increase the row
height in html? cellspacing cellpadding row span col span 0 0 1 0 TEXT TEXT

Carefully read the question and answer accordingly. <prefor> <pre format>
Which html tag is used to display Preformatted texts? <pre text> </pre text> <pre> </pre> </prefor> </pre format> 0 1 0 0 TEXT TEXT
To display
Carefully read the question and answer accordingly. To provide animation contents of To collect None of the
what is the use of forms in html? effects email users input listed options 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
Which of the following is a plain ASCII text file with Action Transaction
embedded HTML commands? Web document document document Web Server 1 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
What is the most important tool for adding colors to
certain areas of the page rather than the entire None of the
background ? Images Tables Fonts listed options 0 1 0 0 TEXT TEXT
<a href="url" <a href="url"
Carefully read the question and answer accordingly. None of the target=" target="new"
How can you open a link in a new browser window? <a href="url" new> listed options _blank"> > 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly. <ol begin="3"
Which link is used to start a list at the count of 3? None of the listed options > <ol list="5"> <ol start="3"> 0 0 0 1 TEXT TEXT
<img src="
http://www. <img src=" <img src="
google. http://www. http://www.
com/logo. google. google.
<img src="http://www. png" com/logo. com/logo.
Carefully read the question and answer accordingly. google.com/logo.png" alternate png" alt png" alt="
What is the correct syntax to add alternative text for an alternate="Logo of text="Logo of text="Logo of Logo of
image? website"/> website"/> website"/> website"/> 0 0 0 1 TEXT TEXT
Space to the
Carefully read the question and answer accordingly. None of the Space to the top and
Using Hspace will add what to your image ? Height to all sides listed options left and right bottom 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly. <h1
Which of the following is correct to align H1 tag to left <h1 tag align alignment = <h1 align =
alignment? None of the given options = "left"></h1> "left"></h1> "left"></h1> 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
Which tag would be used to display power in expresion
(A+B)2 ? <p> <SUP> <SUB> <b> 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
Choose the correct HTML syntax to left-align the <td valign="
content inside a table cell <td align="left"> <tdleft> <td leftalign> left"> 1 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly. A
computer Program that translates one program
instruction at a time into machine language is called
______. Interpreter Compiler CPU Simulator 1 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly. both linking
The process of converting object code into machine and
code is called None of the listed options Compiling compiling Linking 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
The processes of starting or restarting a computer
system by loading instructions from a secondary All the listed
storage device into the computer memory is called Duping Booting Padding options 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
Application Software can run independently of the
system software. State True or False true false 0 1 TEXT TEXT
stores data allows the
indefinitely computer to
Carefully read the question and answer accordingly. All the listed unless you store data
What is RAM is a secondary memory options delete it electronically 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly. both static
Multiple programs can share a single copy of the and dynamic dynamic
library. This is an advantage of ______. None of the listed options linking linking Static linking 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
System Software can run independently of the
application software. State True or False false true 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
When data needs permanent storage __________ is Storage
chosen. None of the listed options RAM both device 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
Which of the following storage is volatile semiconductor memory CD-ROM floppy disk core memory 1 0 0 0 TEXT TEXT
Converting
the object Converting
Carefully read the question and answer accordingly. Converting the source code into the source
Choose all the major steps involved in a compilation code directly into machine machine code into None of the
process code code object code listed options 0 0.5 0.5 0 TEXT TEXT
Carefully read the question and answer accordingly.
The most commonly used standard data code to
represent alphabetical, numerical and punctuation
characters used in electronic data processing system is All the listed
called EBCDIC ASCII BCD options 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
The term associated with the comparison of processing
speeds of different computer system is: MPG EFTS CPS MIPS 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly. Graphics All the given Microsoft
Choose the Application Softwares from the given list MySQL Driver options Word 0.5 0 0 0.5 TEXT TEXT

Carefully read the question and answer accordingly.


Optimization of a source code according to a particular All the listed Java
operating system is the advantage of _____. Borland C++ options JIT Compiler 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
Converting a source code to intermediate code so that
it can run on any operating system provided you have
the JIT for that operating system provides Portability to
a source code. State True or False. false true 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
Which programming language allows control of one or High level Machine All the listed
more software applications? Scripting Language language language options 1 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly. All the listed
Choose all the Storage devices from the given list Hard Drive Flash Drive options RAM 0.5 0.5 0 0 TEXT TEXT
Carefully read the question and answer accordingly. A
single software program can have multiple object files?
State True or False. true false 1 0 TEXT TEXT
Carefully read the question and answer accordingly. All the listed
Choose the System Softwares from the given list Unix Web browser Device driver options 0.5 0 0.5 0 TEXT TEXT
Carefully read the question and answer accordingly. Cache All the listed Virtual
Which memory has the shortest access time? Secondary Memory Memory options Memory 0 1 0 0 TEXT TEXT
Both source
only and
Carefully read the question and answer accordingly. Either source or destination destination only source
Each IP packet contain? destination address address address address 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly. devices and devices and networks and
Port is a communication point between ___________. All the listed options networks processes resources 0 0 1 0 TEXT TEXT
Wireless
Wireless networks are
networks use Wireless faster than
Carefully read the question and answer accordingly. Wireless networks are radio networks are wired
Which statement is FALSE about wireless networks? slower than wired LANs. transmitters. convenient. networks. 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly. IP address
___________ is a segment of a network. Router and Router IP address Subnet 0 0 0 1 TEXT TEXT
Protocol Protocol
defines what defines how
data is data is
Carefully read the question and answer accordingly. Protocol defines when data communicate communicate All the listed
What does Protocol defines is communicated d d options 0 0 0 1 TEXT TEXT
Easier
Carefully read the question and answer accordingly. All the listed access to
What is the benefit of the networking? Easier backups File sharing options resources 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
Find all the high level protocols from the given list SMTP&nbsp; HTTP ARP ICMP 0.5 0.5 0 0 TEXT TEXT
Carefully read the question and answer accordingly. None of the Unicast Broadcast
The last address of IP represents Network address listed options address address 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly. A
hardware networking device used to connect two LANS
or LAN segment Hub Bridge Router Broad band 0 1 0 0 TEXT TEXT

constructs
that connects thirty packets of
personnel computers that data and
can provide more controls error send them
Carefully read the question and answer accordingly. computing power than a detection and None of the across the
A local area network is: minicomputer correction given options network 1 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
What is the address given to a computer connected to
a network called System address IP address SYSID Process ID 0 1 0 0 TEXT TEXT

space
located in the
socket that front of a
peripheral enables computer to
hardware device that device information to install
Carefully read the question and answer accordingly. A allows connection to the attached to a move through additional
port is a Internet computer. a system. drives. 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly. A
logical network that consists of two or more physical
networks WAN Internetwork
Networking LAN 0 1 0 0 TEXT TEXT
SMTP&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
Carefully read the question and answer accordingly. HTTP&nbsp;&nbsp;&nbsp; &nbsp;
Find all the low level protocols from the given list &nbsp;&nbsp;&nbsp; ICMP &nbsp; ARP 0 0.5 0 0.5 TEXT TEXT
&nbsp;
Carefully read the question and answer accordingly. &nbsp;
Which port is a fast connection that is more flexible &nbsp;
than traditional serial and parallel ports? Serial USB Ethernet
&nbsp; Parallel 0 1 0 0 TEXT TEXT
A network
A network with more A network
with more than one exit with only one
Carefully read the question and answer accordingly. A network that has only than one exit and entry entry and no
What is a stub network? one entry and exit point. point. point. exit point. 1 0 0 0 TEXT TEXT
Packets may
Carefully read the question and answer accordingly. Duplicate packets may be arrive out of All the listed A packet may
Why IP protocol is considered as unreliable? generated order options be lost 0 0 1 0 TEXT TEXT
Which of the following is not a Internet connection? DSL WLAN dial-up WWAN 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
How long is an IPv6 address? 64 bits 128 bytes 32 bits 128 bits 0 0 0 1 TEXT TEXT
Circuit
Carefully read the question and answer accordingly. All the listed Cell switched switched
The internet is an example of Packet switched network options network network 1 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
Which tab of task manager in Windows 7 will show
each program you are working on as a Process? Services Processes Process Performance 0 1 0 0 TEXT TEXT

Carefully read the question and answer accordingly. In


Unix, the names of daemons conventionally end in __. "dn" "n" "d" "mn" "dm" 0 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
Any UNIX command which is ended with ___ will run
the command in the background. $ # @ & % 0 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
State whether True or False.
Context is made up of the contents of its registers and
the memory that it is addressing. true false 1 0 TEXT TEXT
Carefully read the question and answer accordingly. In
task manager of Windows 7 the unique process
identifier is denoted as __________. ProcessesID ProcID PID ProcessID 0 0 1 0 TEXT TEXT
Disk and Deadlock &
Carefully read the question and answer accordingly. Driver and Execution None of the Execution Execution
Daemon stands for __________________. Monitor options Monitor Monitor 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly. In all of the
___________ multitasking, the operating system specified
parcels out CPU time slices to each program. cooperative interogative option preemptive 0 0 0 1 TEXT TEXT

Carefully read the question and answer accordingly. In


UNIX which command is used to list a job’s Process ID "jbs -l" "job -l" "jobs -l" "jb -l" 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
Which command is used to bring a background
process to the foreground? "fp" "fg" "bf" "bg" 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
Which command in UNIX is used to get process ID? "pid" "fetchpid" "getid" "getpid" 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
The total number of tasks that can run at any time does
not depend on which of the following factors? Network speed Program Size CPU Speed Memory Size 1 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
State whether True or False.
Multitasking is beneficial in critical applications
involving huge business transactions, false true 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
State whether True or False.
Time Slice is the period of time for which a process is
allowed to run uninterrupted. false true 0 1 TEXT TEXT
all of the
Carefully read the question and answer accordingly. specified
UNIX and Windows 7 uses which type of multitasking? cooperative preemptive option interogative 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
__________ implies that more than one CPU is Multiprocessi Multiprogram
involved. None of the options Multitasking ng ming 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
State whether True or False.
A daemon is a long-running background process that
answers requests for services false true 0 1 TEXT TEXT
Carefully read the question and answer accordingly. In all of the
___________ multitasking, each program can control specified
the CPU for as long as it needs it. interogative cooperative option preemptive 0 1 0 0 TEXT TEXT

Carefully read the question and answer accordingly.


State whether True or False.
The Unix kernel can keep track of many processes at
once, dividing its time between the jobs submitted to it. false true 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
Which command lists all running processes in UNIX ? ps prs prcs prc 1 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly. prcs – ef |
Which command is used to list down all the processes prc – ef | grep prs – ef | grep grep
owned by you? ps – ef | grep username username username username 1 0 0 0 TEXT TEXT

Carefully read the question and answer accordingly. In


UNIX which command is used to get information on “/proc/sysinfo “/proc/cpuinfo “/proc/cpudet
CPU Model, CPU MHz, CPU Cores, Address size etc? “/proc/cpu” ” ” ails” 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
Which option is used to get long listing details of all
running processes in UNIX ? "-d" "-l" "-f" "-e" 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
UNIX lets us run more than one program inside the Control MultiJob
terminal, which is called as “_____________”. Control Job MultiJob Control Job Control 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly. Simple Symmetric Symmetric
With respect to Android OS what does SMP stands Multiprogram Multiprogram Multiprocessi
for? Simple Multiprocessing ming ming ng 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
Which command is used to view the disk usage in
UNIX? du cd df rm 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
Which of the following are valid types of physical
storage used in z/OS (Choose 2) Tertiarry Auxiliary Secondary Central Primary 0 0.5 0 0.5 0 TEXT TEXT
Carefully read the question and answer accordingly. Task Task Task
How can one view the kernel Paged & NonPaged Task Manager -- Manager -- Manager -- Manager--
memory in windows 7 operating system? Performance Processes. Application Cpu Usage 1 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
Which command is used to view disk usage by a
directory or file in UNIX? rm cd df du 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly. Paged
Which type of Memory allocation assigns consecutive Contiguous memory Memory None of the Virtual
memory blocks to a process allocation Management options. Memory 1 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
The process of translating virtual addresses into real
addresses is called __________ . None of the options. paging swapping mapping 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
The ________ command will display a continually
updating report of system resource usage in UNIX. top df du rm 1 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
Each process on 32-bit Microsoft Windows has its own
virtual address space that enables addressing up to
_______________ of memory. 32 gigabytes 8 gigabytes 16 gigabytes 4 gigabytes 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
Which type of Memory allocation uses a space that is
larger than the actual amount of RAM present by Contiguous
temporarily transferring some contents from RAM to a Paged Memory Virtual None of the memory
disk. Management Memory options. allocation 0 1 0 0 TEXT TEXT

Carefully read the question and answer accordingly.


With respect to Virtual Storage in z/OS :
A block of External Storage is called as ____________ None of the options. Pages Frames Slots 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
With respect to Virtual Storage in z/OS :
A block of Virtual Storage is called as ____________ None of the options. Frames Slots Pages 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
The __________ of a process is the collection of pages
in the virtual address space of the process that are
currently resident in physical memory working set paging set group set map set 1 0 0 0 TEXT TEXT

Carefully read the question and answer accordingly.


The Operating System’s responsibility for allocating
primary memory to processes, and for assisting the
programmer in loading and storing the contents of the
primary memory is termed as Storage Memory Data
____________________. None of the options. Management Management Management 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
_________ is an area of memory used for dynamic
memory allocation. It handles the dynamic memory
needs of a program, Thread Array Stack Heap 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
________ is portion of memory, meant to store the
local variables and process registers of an application
program. Heap Array Stack Thread 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
State whether True or False.
Primary memory is a limited resource that cannot
contain all active processes in the system. false true 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
With respect to Virtual Storage in z/OS : None of the
A block of Internal Storage is called as ____________ Slots options. Frames Pages 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
State whether True or False. In UNIX operating
sysytem du command along with –h option is used to
obtain the details of hidden files. true false 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
Which type of Memory allocation supports paging that Contiguous Paged
causes every logical address to be translated to a memory Memory None of the
physical address Virtual Memory allocation Management options. 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
There are _______ ways of memory allocations. two five six three 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly. Program Program
In Operating System (OS) PCB Stands for None of the control content
___________________. Process control Blocks options Blocks Blocks 1 0 0 0 TEXT TEXT
Computer
Computer Computer
Hardware
Hardware Hardware
and
Carefully read the question and answer accordingly. A Operating System and its and its and
Operating
programmer interacts with the ___________________. Utilities. Utilities. Applications 1 0 0 0 TEXT TEXT
System .
Carefully read the question and answer accordingly.
Which of the following is a type of operating system? Distributed All of them Multi-user Embedded Real-time 0 1 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
Which component of Operating System (OS) is
providing CPU Scheduling, Process management,
Memory management and communication between Command
hardware and software components? Shell Kernel Debugger Processor 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
State whether True or False.
Performance monitors fall under utilities of Operating
System (OS). true false 1 0 TEXT TEXT
Carefully read the question and answer accordingly. In
Operating System (OS) which program interprets the
command typed by user? Complier Debugger Kernel Shell 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
There are ____ main components in the Structure of an
Operating System (OS). two one four three 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
State whether True or False.
Editors fall under utilities of Operating System (OS). false true 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
Deadlock handling mechanism falls under what key Memory Process File
function of Operating System (OS) ? I/O System Management Management Management Management 0 0 1 0 TEXT TEXT
Intelligent Intelligent Interactive
Software System Software
Carefully read the question and answer accordingly. Interactive System Productivity Productivity None of the Productivity
With respect to z/OS what does ISPF Stands for? Productivity Facility Facility Facility listed options Facility 1 0 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
State whether True or False.
Operating System (OS) ensures security by validating
the users while any process is invoked. false true 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
Which of the following runs on computer hardware and Application Operating
serve as platform for other software to run on? System Software Software System All of them 0 0 1 0 TEXT TEXT

Carefully read the question and answer accordingly.


State whether True or False.
Operating System (OS) creates a process when an
instance of a program is loaded into the main memory. false true 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
Which of the following is a type of operating sysytem Interactive
used in ATMs? Batch Processing RTOS Distributed Processing 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
Which of the following is/are NOT components in the Command
Structure of an Operating System (OS)? Kernel Debugger Complier Processor Shell 0 0.5 0.5 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
Which of the following is a type of operating system Interactive Batch
used in stock and billing systems? Distributed Processing RTOS Processing 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly. none of the
Operating System is a ________________ Software. both System & Application Application listed options System 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
State whether True or False.
A set of processes is deadlocked if each process in the
set is waiting for an event that only another process in
the set can cause. false true 0 1 TEXT TEXT
Carefully read the question and answer accordingly. Time Slicing Non of the Time Sharing
With respect to z/OS what does TSO Stands for? Timer Set Option Option options Option 0 0 0 1 TEXT TEXT

I. APPS II. I. UTILITIES


OPERATING I. APPS II. II.
SYSTEM III. UTILITIES III. OPERATING
UTILITIES OPERATING SYSTEM III.
I. UTILITIES II. APPS III. IV. SYSTEM IV. APPS IV.
Carefully read the question and answer accordingly. OPERATING SYSTEM IV. COMPUTER COMPUTER COMPUTER
Choose the correct order from top to bottom. COMPUTER HARDWARE HARDWARE HARDWARE HARDWARE 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
Which of the following is not considered as key funtion File I/O System Process None of the
of Operating System (OS). Memory Management Management Management Management listed options 0 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
State whether True or False.
z/os is an operating system developed by IBM for
mainframe computers. true false 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
State whether True or False.
In GUI the user selects a picture or icons available to
perform a task. true false 1 0 TEXT TEXT

Carefully read the question and answer accordingly.


State which statement below are true.
Statement I : An event-driven system design of RTOS Statement I is
switches between tasks based on their priorities. Both FALSE & Both
Statement II: A time-sharing system design of RTOS Statement I is TRUE & Statement I & Statement II Statement I &
switch tasks based on clock interrupts. Statement II is FALSE II are FALSE is TRUE II are TRUE 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
___________ is an interface between the user and Command
Operating System (OS). Shell Kernel Debugger Processor 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
State whether True or False.
z/OS is NOT a Multiuser Operating System (OS). false true 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
Which of the following falls under Command None of the
Processor? both CLI & GUI GUI CLI listed options 1 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
Scheduling is the process of ________________ controlling & controlling &
messages sent to a processor. sharing prioritizing sharing prioritizing controlling 0 1 0 0 0 TEXT TEXT
A thread with
When a running thread a higher
Carefully read the question and answer accordingly. needs to wait, it all of the priority has A running The time
Which of the following are most common reasons for a relinquishes the remainder specified become thread needs slice has
context switch? of its time slice. option ready to run. to wait. elapsed. 0 1 0 0 0 TEXT TEXT

both High
level
Carefully read the question and answer accordingly. (memory) &
___________ uses multiple queues to select the next Low level Low level
process, out of the processes in memory, to get a time High level (memory) (CPU) (CPU) None of the
quantum. scheduler scheduler scheduler listed options 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
State whether True or False.
In Windows 7 the Task Scheduler wizard is used to
create a task that opens the program automatically
according to the schedule you choose. false true 0 1 TEXT TEXT

Carefully read the question and answer accordingly.


The steps in a context switch are randomly arranged
below. Identify the correct order
I. Place the thread that just finished executing at the
end of the queue for its priority.
II. Save the context of the thread that just finished
executing.
III. Remove the thread at the head of the queue, load
its context, and execute it.
IV. Find the highest priority queue that contains ready II -> I -> IV -> II -> I -> III -> II -> III -> IV -
threads. I -> III -> IV -> II III IV >I 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly. zero (lowest) zero (lowest) zero (lowest)
In Windows 7 the priority levels range from to 10 to 15 to 31
___________. None of the options (highest). (highest). (highest). 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
The scheduler maintains a ______ of executable None of the
threads for each priority level. queue stack options heap 1 0 0 0 TEXT TEXT

Make sure
Eliminate To maintain a each process
highs and constant is consumes
Make sure each process is lows in the amount of specific
Carefully read the question and answer accordingly. completed within a processor’s work for the amount of
Which of the following is not goals of scheduling? reasonable time frame workload processor. memory. 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
UNIX uses ___-level scheduling Two one Four Three 1 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
State whether True or False.
Processes scheduling in which the scheduler selects
tasks to run based on their priority is called Priority
Scheduling. true false 1 0 TEXT TEXT
Carefully read the question and answer accordingly. In
z/OS there are a maximum of ___ name segments
which can make up a data set name 34 44 64 22 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
Which command is used to search for information in a None of the
file or files? search listed options find grep grp 0 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
___________________, sometimes referred to as file
descriptors, are data structures that hold information File Control Fic Content File Content
about a file. Fix Control Blocks Blocks Blocks Blocks 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
State whether True or False.
The command "mv" is used to move and also rename a
file. false true 0 1 TEXT TEXT
Carefully read the question and answer accordingly. In FILE_NAME_
UNIX a file name may not exceed ___________. None of the options. MAX FILE_MAX NAME_MAX 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
Which Command is used to find out what directory you
are working in? pwd more ncftp print 1 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly. Only PS &
Which of the following is a valid type of File in z/OS. All PS,PDS & VSAM PS VSAM PDS PDS 1 0 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
Which of the following is the Korn shell ( ksh)
initialization script. .kshrcs .kshrc .kcshr .kshc 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
State whether True or False.
Partitioned Data Set is similar to File in Windows. true false 0 1 TEXT TEXT

Carefully read the question and answer accordingly.


State whether True or False.
Files are used to store a variety of different types of
information, such as programs, documents,
spreadsheets, videos, sounds, pictures and record-
based data. true false 1 0 TEXT TEXT
Carefully read the question and answer accordingly. Statement I is
State which statement below are ture. TRUE & Both Both
Statement I : "ls -r" Displays files in reverse order. Statement I is FALSE & Statement II Statement I & Statement I &
Statement II: "ls -R" Displays subdirectories as well. Statement II is TRUE is FALSE II are TRUE II are FALSE 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
File ownership is an important component of an OS
that provides a secure method for storing files.
Ther are Total __ number of permissions on a file
which can be defined in UNIX. 8 10 12 9 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly. In
mainframe system the block of data is called as a
________. tablespace table Record cell 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
Which command can be used to display/create a new
file. crt ctr cat create 0 0 1 0 TEXT TEXT
Virtual Virtual Virtual
Storage Storage System
Carefully read the question and answer accordingly. Virtual System Advancement Access Access
What does VSAM stands for? Advancement Method Method Method Method 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
Which command is used to change the permissions of
a file or directory? chmod change cmhd chmd 1 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
Which of the following is the C shell ( csh) initialization
script. .cshr .cshc .cshrcs .cshrc 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
Which command is used if you want to work on a
computer different from the one you are currently
working on because that remote machine might be
faster. chmd pwd grep rsh 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly. A
dataset in z/OS should have a Unique name of Max. __
characters. 64 40 33 44 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
Which option is specified to display invisible files in "ls"
command "-d" "-b" "-a" "-f" 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly. In
UNIX ___ command lists all files in the directory that
match the name if specified. rm ts top ls 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly. None of the
Files are termed as _________ in z/OS. Record Datasets table options. 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
State whether True or False.
Files can be renamed using the "rm" command. false true 1 0 TEXT TEXT
Carefully read the question and answer accordingly. File Control Fix Control File Content
What does FCB stands for ? Fic Content Blocks Blocks Blocks Blocks 0 1 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
Which of the following is the Bourne shell ( sh)
initialization script. .rhosts .cshrc .kshrc .profile 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
Which of the following is not hidden/invisible file in
UNIX? .kshrc .profile .rhosts .cshrcs 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
State whether True or False.
Physical Sequential dataset is similar to Folder in
Windows false true 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
Which command is use to remove a directory? clean rm remove rmdir 0 0 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
Which of the following is not valid permission of a file or Read & None of the
folder in Windows 7? Read Write execute Options Full control 0 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
Thread lifecycle has how many states? 3 6 2 5 4 0 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly. A
runnable thread enters the ____________ state when it
completes its task or otherwise terminates. Timed Waiting Waiting New Terminated Runnable 0 0 0 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
State whether True or False.
A thread transitions back to the runnable state only
when another thread signals the waiting thread to
continue executing. true false 1 0 TEXT TEXT
Carefully read the question and answer accordingly. A
thread in ______________ state is considered to be Timed
executing its task. Runnable Terminated Waiting Waiting New 1 0 0 0 0 TEXT TEXT
Carefully read the question and answer accordingly.
State whether True or False.
Multithreading is the ability of an operating system to
concurrently run programs that have been divided into
subcomponents or threads. false true 0 1 TEXT TEXT

Carefully read the question and answer accordingly.


State whether True or False.
Multithreading in an interactive application may allow a
program to continue running even if part of it is blocked
or is performing a lengthy operation, thereby increasing
responsiveness to the user. true false 1 0 TEXT TEXT
Carefully read the question and answer accordingly.
State whether True or False.
Threads in Windows 7 are represented as objects that
are created, maintained, and destroyed by the Process
Manager. false true 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
State whether True or False.
All thread of a single process does not share the same
resources that are assigned to their corresponding
process. true false 0 1 TEXT TEXT
Carefully read the question and answer accordingly.
State whether True or False.
Thread refers to a path through a program’s
instructions that can be scheduled for execution
separately false true 0 1 TEXT TEXT
Carefully read the question and answer accordingly. A
thread in ______________ state transitions back to the
runnable state when that time interval expires or when Timed
the event it is waiting for occurs Waiting Terminated Waiting New Runnable 0 0 1 0 0 TEXT TEXT

You might also like