0% found this document useful (0 votes)
87 views75 pages

All Milestone MCQ PDF 585813515 All Milestone MCQ PDF

The document contains a series of multiple-choice questions (MCQs) related to computer programming, specifically focusing on Java and its concepts. It includes questions about Java collections, class hierarchies, exception handling, and access modifiers. The document appears to be a study resource for students preparing for exams in computer programming.

Uploaded by

Sanket
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
87 views75 pages

All Milestone MCQ PDF 585813515 All Milestone MCQ PDF

The document contains a series of multiple-choice questions (MCQs) related to computer programming, specifically focusing on Java and its concepts. It includes questions about Java collections, class hierarchies, exception handling, and access modifiers. The document appears to be a study resource for students preparing for exams in computer programming.

Uploaded by

Sanket
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 75

lOMoARcPSD|43369215

585813515 All Milestone MCQ pdf

Computer Programming (Dr. B. R. Ambedkar Open University)

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

VELALAR COLLEGE OF ENGINEERING AND TECHNOLOGY


(Accredited by NAAC with ‘A’ Grade & Accredited by NBA)
Thindal, Erode - 638012
(Autonomous)
WIPRO PRP TRAINING
Milestone 1 MCQs
1. Which of these implementations is provided by the java.util.package as part of the Collections
Framework?
a.ArraySet b.ArrayMap c.LinkedHashSet d.TreeList
2. What is the output?
public class Test{
public static void main(String args[]){
System.out.println(6^4);
}
}
a.1296 b.24 c.2 d.Compilation Error
3. Given the following
Class Vehicle{}
Class FourWheeler extends Vehicle{}
Class Car extends FourWheeler{}
public class TestVehicle
{
public static void main(String[] args)
{
Vehicle v = new Vehicle();
FourWheeler f = new FourWheeler();
Car c = new Car();
xxxxxx
}
}
Which of the following statement is legal,which can be substituted for xxxxxx?
a.v=c b.c=v c.f=v d.c=f
4. What is the result of attempting to compile and run the program?
import static java.lang.System.out;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.SortedMap;
public class CollectionsThree{
public static void main(String[] args){
Object o = new LinkedHashmap();
out.format(“%b,%b”,o instanceof Map,o instanceof SortedMap);
}
}
a.false,false b.false,true c.true,false d.true,true
5. Given A.java contains
class A{public static void main(String[] args){}} //1
and B.java contains
class B{public static void main(String[] args){}} //2
What is the result of attempting to compile each of the two class declarations and invoke each main
method from the command line?
a.Compile time error at line 1
b.Compile time error at line 2
c.An attempt to run A from the command line fails

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

d.An attempt to run B from the command line fails


6. Which statement is true?
a.Public methods of a superclass cannot be overridden in subclasses.
b.Protected methods of a superclass cannot be overridden in subclasses.
c.Methods with default access in a superclass cannot be overridden in subclasses.
d.Provate methods of a superclass cannot be overridden in subclasses.
7. What is the output?
import java.util.Queue;
import java.util.LinkedList;
public class MyQueue{
public static void main(String[] args){
Queue q = new LinkedList();
q.offer(“Banana”);
q.offer(“Apple”);
q.offer(“Orange”);
System.out.println(q);
}
}
a.Prints[Banana,Apple,Orange] c.Prints[Orange,Apple,Banana]
b.Prints[Apple,Banana,Orange] d.The order in which it prints is not predictable
8. Given the following
1.public class ThreeConst{
2.public static void main(String[] args){
new ThreeConst();
4.}
5. public void ThreeConst(int x){
6. System.out.print(“” + (x*2));
7.}
8. public void ThreeConst(long x){
9. System.out.print(“” + x);
10.}
11.
12. public void ThreeConst(){
13. System.out.print(“no-arg”);
14.}
15.}
What is the result?

a.8 4 no-arg b.no-arg 8 4 c.Compilation fails d.No output is produced


9. Which one of the classes implements the interface SortedMap?
a.HashMap b.HashTable c.TreeMap d.TreeSet
10. Given the following
Class Dogs{
public String toString(){
return “theDogs”;
}
}
public class TestDogs{
public static void main(String[] args){
Dogs[][] dogs=new Dogs[3][];
System.out.println(dogs[2][0].toString());
}
}
What is the result?
a.null b.theDogs

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

c.Compilation fails d.NullPointerException is thrown at runtime


11. You want subclasses in any package to have access members of a superclass. Which is the most
restrictive access modifier that will accomplish this objective?
a) Public b) Private c) Protected d) default
12. What will happen if you try to compile and run the following code?
int a=200;
byte b=a;
System.out.println(“The value of b is”+b);
a) it will compile and print The value of b is 200 c) compile-time error
b) it will compile but cause an error at runtime d) it will compile and print The value of b is -56
13. Consider the following class hierarchies
class A{}
class B extends A{}
class C extends B{}
And the following method declaration
public B doSomething(){
//some valid code fragments
return xx;
}

Object of which class(from the hierarchy shown above) can be safety substituted in place of xx in the
method doSomething()?
a) Object of class A c) Object of class C
b) An array object of class B d) An array object of class C

14. Which one of the following is a core interface in the collection framework?
a) Set b) Stack c) Array d) Tree
15. Which class in the collection framework has its implementation based on Hash Table and doubly
Linked list data structure?
a) Hashtable b) HashSet c) Vector d) LinkedHashSet
EXPLANATION:-The LinkedHashSet class implements the Set interface and uses the hash-table data
structure to store the elements.
16. What is the output?
public class TestLiterals{
public static void main(String[] args){
float f1=2.0;
float f2=4.0f;
float result=f1*f2;
System.out.println(result);
}}
A. A value which is exactly 8.0 C. Compilation error at Line 4
B. Compilation error at Line 3 D. Compilation error at Line 5
17. What is the output?
Given the following.
public class RTExpect{
public static void throwit(){
System.out.println(“throwit”);
throw new RuntimeExpection();
}
public static void main(String [] args){
try{
System.out.println(“hello”);
throwit();
}
catch (Expection re){
System.out.println(“caught”);
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

}
finally{
System.out.println(“finally”);
}
System.out.println(“after”);
}}
A. hello throwit caught D. hello throwit caught finally after
B. hello throwit Runtime Expection caught after RuntimeException
C. hello throwit caught finally after
18. public class ExceptionTest{
public static void main(String[] args){
try{
ExceptionTest a=new ExceptionTest();
a.badmethod();
System.out.println(“A”);
}
catch (Exception e){
System.out.println(“B”);
}
finally{
System.out.println(“C”);
}}
void badmethod(){
throw new Error();
}
}
A. BC followed by Error exception C. C followed by Error Exception
B. Error Exception followed by BC D. Error Exception followed by C

19. What will be the result of attempting to complete and run the following program?
public class polymorphism{
public static void main(String[]args){
Aref1 = new C();
Bref2 = (B)ref1;
System.out.println(ref2.f());
}}
class A{int f(){return 0;}}
class B extends A{int f(){return 1;}}
class C extends B{int f(){return 2;}}
A.The program will fail to compile
B. The program will compile without error, but will throw a ClasscastException when run
C. The program will compile without error and print 1 when run
D. The program will compile without error and print 2 when run
20. compile and/or run the program?
package mypack;
public class A {
public void m1() {System.out.print("A.m1");} }
class B {
public static void main(String[] args) {
A a = new A(); // line 1
a.m1(); // line 2
}}
a) prints: A.m1 c) Compile-time error at line 2
b) Compile-time error at line 1 d) Run-time error at line 1
21. What is the output ?

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

class Super{
int i=0;
Super(String s){
i=10;
}
}
class Sub extends Super {
Sub(String s){
i=20;
}
public static void main(String args[]) {
Sub b=new Sub("hello");
System.out.println(b.i);
} }
a) Compilation Error b) Runtime Error c) 10 d) 20
Explaination: if u have parameterized constructor then there must be a default constructor.
22. What is the result of attempting to compile and run the program
// Class A is declared in a file named A.java.
package pack1;
public class A {
void m1() {System.out.print("A.m1");}
}
// Class D is declared in a file named D.java.
package pack1.pack2;
import pack1.A;
public class D extends A{
public static void main(String[] args) {
A a = new A(); // line 1
a.m1(); // line 2
}}
a) Prints: A.m1 c) Compile-time error at line 2.
b) Compile-time error at line1. d) Run-time error at line 1.
Explaination: m1() in A is not visible in class D

23. What gets printed when the following gets compiled and run:
public class example {
public static void main(String args[]) {
int x = 0;
if(x > 0) x = 1;
switch(x) {
case 1: System.out.print(“1”);
case 0: System.out.print(“0”);
case 2: System.out.print(“2”);
break;
} } }
a) 0 b) 102 c) 1 d) 02
24. A software blueprint for objects is called a/an
a) Interface b) Class c) Prototype d) method
25. What is the output when the following code is compiled and/or executed?
public class Test {
private void method(){
System.out.println(“method”);
throw new RuntimeException();
}
public static void main(String[] args){

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

Test t = new Test();


t.method();
} }
a) Compile time error c) Throws IllegalAccessException
b) Throws RuntimeException d) No output

26. Which of the following layout manager arranges components along north, south, east, west and
center of the container?
a) BorderLayout b) BoxLayout c) FlowLayout d) GridLayout
27. Which of the following is not a primitive data type
a) int b) bool c) float d) long
28. Which of the following keyword can be used for intentionally throwing user defined exceptions?
a) throw b) throws c) finally d) try
29. Class A{
A(){}
}
Class B{}
Class C{
Public static void main(String arg[]){
}
}
a) Compile and run b) will not compile c) will throw runtime exception
30. Class A{
A(){}
}
Class B{
B(int x){}
}
Class C{
Public static void main(String arg[]){
A ab=new A();
B cd=new B();
}
}
a) Compile and run b) will not compile c) will throw runtime exception
31. Class A{
A(){}
}
Class B{
B(){}
B(int a){super(200);}
}
Class C{
Public static void main(String arg[]){
A ab=new A();
B cd=new B(23);
}
}
a. Compile and run b. will not compile c.will throw runtime exception
32. Consider the following program
class A{
Psvm(String a[]){

int x[]={1,2,3};
try{

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

for(int i=0;i<x.length;i++){
S.op(x[i]);
}
S.o.p(“Done”);
}
Catch(NullPointerException ne){
S.o.p(“Catch”);
}
Finally{
S.o.p(“Final”);
}
S.o.p(“XXX”);
}
}
a) Compile time error c) Prints:123DoneFinalXXX
b) Run time error d) Prints123catchdonefinalxxx
33. Consider the following program
Class A{
Psvm(String a[]){
int x[]={1,2,3};
try{
For(int i=0;i<=x.length;i++){
S.op(x[i]);
}
S.o.p(“Done”);
}
Catch(ArrayIndexOutofBoundException ae){
S.o.p(“Catch”);
}
Finally{
S.o.p(“Final”);
}
S.o.p(“XXX”);
}
}
a) Compile time err c) Prints:123CatchFinalXXX
b) Run time err d) Prints123catchdonefinalxxx
34. Protected member are visible in
a) Inside same class c) inside same package and subclasses of
b) inside same package other package

35. Which of the following is a proper declaration a final method is java?


a) public final method(); c) public final void method(){}
b) public abstract final method(); d) public void method(){}

36. is the modifier is used to avoid a class to be inherited


a) Abstract b) Final c) static d) none of the above
37. Which of the following statements is true ?
(i) Constructor can be overloaded.
(ii) Constructor can return a value.
(iii) Constructor name should be the same as the class name.
(iv) Constructor can take input parameters.
a) (i),(ii),(iii) and (iv) c) (i) and (ii) only
b) (i), (iii) and (iv) only d) (ii),(iii) and (iv) only
38. A function can be abstract and final at the same time.

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

a) True b) False c) Ignore this option d) Ignore this option

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

39. Which of the following is the operator used to generate an exception programmatically
a) throws b) throw c) catch d) try
40. Which of these array declarations and initialization are legal
(i) int arr[4] = new int[4]; (iii) int arr[] = new int[4];
(ii) int[4] arr = new int[4]; (iv) int[] arr = new int[4];

a) all of the above b) (i), (ii) c) (iii) d) (iii) and (iv)


41. The synchronized modifier is used to control access to critical code in multithreaded programs.
a) False b) True c) Ignore d) Ignore
42. Which of the following will read a set of words from the command line?
a) System.in.read()
b) System.in.readLine()
c) new BufferedReader(new InputStreamReader(System.in)).readLine()
d) none of the above
43. In a pure java class the method is Static block is called before the main() method
a) True b) False c) Ignore d) Ignore
44. Method Overloading can be done using
a) Number of Parameters c) Return Type
b) Number and type of Parameters d) None of the above
45. Constructor (Methods) have Return Type

a) True b) False c) NA d) NA
46. is the Root Class of all Exception classes
a) Exception b) Error c) Throws d) Throwable
47. is the "Block of code" that is always executed (normal execution)
a) Catch (Exception Ex) c) Finally
b) Destructor d) None of the above

48. In a try-catch-finally construct, the finally block is executed


a) Only when an exception Is caught d) Only when the catch block has a "return"
b) Only when no exception is caught statement.
c) Always
49. Which of the following statements is not correct?
a)Java is based on object oriented concepts c) Java is portable
b) Java is platform dependent d) None of the above
50. Which of the following code snippet is wrong:

(i) public class Myclass implements IA, IB, IC // IA, IB, IC are different interfaces
{
MyClass mc = new Myclass();
}
(ii) public class Myclass extends A, B, C // A, B, C are classes (may be abstract)
{
MyClass mc = new Myclass();
}
a) i b)ii c) both i and ii d)NA
Explaination: Multiple inheritance is not allowed in java.
51. Which of these is the valid declaration for the main method?
a) public void main(); c) public static void main(String);
b) public static void main (String args[]) d) public static int main(String args[])
52. Which of the following statements is true?
a) Abstract modifier can be applied to classes c) An abstract class can have all or more abstract
and methods. methods
b) The abstract class cannot be instantiated. d) All of the above

53. If no access modifier is specified in Java the default access modifier assumed is
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

a) private b) public c) protected d) package level


54. Which of the following is NOT a package in Java?
a) awt b) lang c) util d) jfc

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

55. We can extend from number of classes


a) Zero b) One c) Two d) Three
56. Integer is a
a) Keyword b) Wrapper Class c) Data Type d) Constructor
57. is the concept by which one class is inherited from more than one super class
a) Multiple inheritances c) Single inheritance
b) Mutilevel inheritance d) None of the above

58. To make salary in the following class definition read-only:


class Employee
{ double salary;
} a good approach would be to
a) Make the employee class private
b) Make salary protected
c) Make salary private and define a method called getSalary()
d) Make salary private and define methods called getSalary() and setSalary()
59. public class Compare
{ public static void main(String args[])
{ int x = 10, y;
if (x < 10) y =1 ;
if (x >=10) y =2 ;
System.out.println("Y is " + y);
}}
a) Program compiles and prints Y is 0
b) Program throws a runtime exception
c) Program does not compile saying Y is not initialized
d) Program prints one of the following
Y is 1
Y is 2
60. What gets printed on the standard output when the class below is compiled and executed by entering
"java test This is a test"
public class test
{
public static void main(String args[])
{
System.out.println(args[0]+ " " + args[args.length]);
}
}
a) Program will print "java this" d) Will throw
b) Program will print "java test" ArrayIndexOutOfBoundsException
c) program will print "this test"

61. Garbage Collector can be invoked to immediately recover unused memory


a) TRUE b) FALSE c) Ignore this choice d) Ignore this choice
62. Which Class is the superclass of all Java classes
a) Class b) Object c) Interface d) Container
63. An abstract class can have static methods that are not abstract.
a) TRUE b) FALSE c) Ignore this choice d) Ignore this choice
64. A java application should not try to catch an "Error"
a) TRUE b) FALSE c) Ignore this choice d) Ignore this choice
65. What is the default access specifier in Java
a) Private d) Don't use any keyword at all (Make’s it
b) Protected default package level)
c) Final

66. You can implement the selected methods of interface. This can be achieved by
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

a) inner class b) Anonymous inner class

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

c) Adapter class d) Static inner class


67. Pointer facility is available in Java as
a) No such facility in Java c) Pointer itself
b) Object References d) Classes

68. When we have a „catch‟ block in Java, it is mandatory to have


a) Finally block c) Try block
b) Throws block d) No need to have any mandatory block

69. System.in can be used to directly read lines from the console
a) true b) false c) Ignore this option d) Ignore this option
70. From OO point of view which of the following is better option for creating a thread
a) extending Thread class c) implementing Runnable interface
b) extending Runnable interface d) none of the above
71. 'this' is used for referring
a) current object c) super class object
b) any object used in the application d) none of the above

72. In an Object-Oriented system, objects interact with each other by sending and receiving _
a) arguments c) methods
b) messages d) None of these
73. Given these class definitions
class Superclass{}
class Subclass1 extends Superclass{}
and these objects
Superclass a = new SuperClass();
Subclass1 b = new Subclass1();

Which of the following explains the result of the statement a=b?


a) Compile time Error c) No error at all
b) Only run time Error d) Ignore this option this choice
74. Given these code snippets,
Boolean b1 = new Boolean(true);
Boolean b2 = new Boolean (true);

Which expression is legal java expression that returns true?


a) b1==b2 b) b1.equals(b2) c) both a & b d) b1 | b2
75. Can a method in java be private and static?
a) Yes b) No
76. How do you implement pass-by-reference in Java?
a) Using classes b) Using Objects c) Using pointers d) Using Wrapper Classes
77. What exception will be thrown from the code given below:
class Arr
{ public static void main(String[] args)
{ int[] ia = new int[2];
ia[2] = 2;
System.out.println(ia[2]);
}
}
a) NullPointerException c) IllegalAccessException
b) ArrayIndexOutOfBoundsException d) No exception will be thrown
78. A package is a collection of
a) Classes and Interfaces only c) C) Interfaces and packages only
b) Classes ,Interfaces, and packages d) Only Interfaces and Abstract classes

79. What is true with the following statement is java super();


Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

[ i] calls the super class constructor


[ ii] is optional because there is default call to the super
class constructor
[iii] has to be the first executable statement in the subclass

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

constructor
[ iv] fails if there is neither implicit nor explicit zero parameter
constructor in the super class.
a) all of the above b) [i], [ii],[iii] c) [i], [ii] d) [i], [ii],[iv]
80. Ture or False?
There are methods, System.gc() and Runtime.gc() that look as of they run the garbage collector but
even these methods do not have any control on the garbage collection process.
a) False b) True c) Ignore this option d) Ignore this option
81. What are the advantages of wrapper classes in Java?
a) Java contains many subsystems that work only with objects and not with primitive types
b) They are more object oriented than primitive data types
c) They can encapsulate the power of the functions related with something that they wrap which
primitives cannot do.
d) all of the above
82. What happens when object of the file class is garbage collected
a) file is permanently deleted from the hard disk
b) file is deleted but can be retrieved using some utilities
c) file is not deleted but the reference to the file is not available anymore.
d) file is closed and made inaccessible.
83. Which of the following statements are correct regarding the Object class in Java
[i] this is super class of all other classes in Java.
[ii] when you want to write a generic method which needs to accept any kind of object you can use this
class
[iii] Object o=new Emp();
[iv] Emp e=new Object();
a) all of the above b) [i], [ii], [iii] c) [i], [ii] d) [i], [iii]
84. Which of the following is true about the abstract classes and interface
a) Abstract class may contain some implemented, some unimplemented methods. Interface
cannot have implemented ones.
b) Abstract classes can have instances and interfaces cannot.
c) Abstract classes are useful without inheritance and interfaces have to be implemented to be usable.
d) Interfaces cannot contain anything other than method declarations while as abstract classes can
contain variables as well.
85. We can synchronize
[i] block [ii] method [iii] object [iv] class
a) only [ii] b) [ii], [iii] c) [i], [ii], [iii], [iv] d) none of the above
86. What access control keyword should you use to enable other classes to access a method freely within
its package, but to restrict classes outside of the package from accessing that method?
a) private c) protected
b) public d) Do not supply an access control keyword
87. Multiple inheritance is achieved in Java with

a) Interfaces b) classes c) abstract classes d) extends keyword


88. What are the uses of an Interface?
a) It allows multiple interface inheritance
b) It helps to use the Polymorphism feature of OOP
c) It helps to follow a specific standard of functions among the similar classes.
d) All of the above
89. What is overriding?
a) Writing a function in the child class, which has the same name and same function signature as
that of the function in the parent class is called overriding.
b) Overriding is same as overloading but implemented in a parent child relationship between classes.
c) Writing a function in the child class, which has the same name but different function
signature as that of the function in the parent class is called overriding.
d) None of the above

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

90. How to create your own exception class


a) You cannot create your own exception class
b) You have to inherit your class from Exception/Throwable
c) You have to implement the Serializable interface
d) You have to extend your class from Error class
91. Which of the following is a proper declaration of abstract methods in java?
a) public method(); c) public abstract void method(){}
b) public abstract method(); d) public abstract void method();
92. In Java the bytecode is always contained in

a) .jar file b) .class file c) .java file d) .exe file


93. Bytecode has to be
a) interpreted by the JVM c) either of the above
b) compiled by the JIT d) both a,b
94. Byte code verifier is used to check whether the code
a) Memory access violations c) attempt to change the object type illegaly
b) violates access rights on objects d) all of the above

95. A is a part of JVM that loads all classes that are required for the execution of the java program.
a) JRE b) bytecode loader c) class verifier d) classloader
96. Which of the following statements are true?
1] Abstract class cannot be instantiated
2] We cannot declare abstract constructors
3] We may declare abstract static methods
a) 1 is true b) 2 is true c) 1 & 2 are true d) All the above are true
97.keyword is used to declare class as abstract
a) public b) private c) abstract
98. What will be the output?
public class TestConstructor extends Object{
TestConstructor(){
super();
this(10);
}
TestConstructor(int i){
this(i,11);
}
TestConstructor(int i,int j){
System.out.println(“i=”+i+”j=”+j);
}
public static void main(String[] args){
TestConstructor tc=new TestConstructor();
}}
a.No output b.i=10 j=11 c.compilation error d.runtime error
Explaination: this(10) should be first statement of constructor.
99. Given:
1. Abstract class AbstractClass{
2. void setup(){ }
3. abstract int execute();
4. }
5. class EC extends Abstractclass{
6. int execute(){
7. System.out.println(“execute of EC invoked”);
8. return 0;
9. }
10. }
11. Public class TestEC{
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

12. Public static void main(String[] args){


13. EC ec=new EC();
14. ec.setup();
15. ec.execute();
16.}
17.}
What is the expected behavior?
a.Compilation error at line 2. c.Runtime error occurs.
b.Compilation error at line 14 d.Execute of EC invoked.
100. Given the following.
1.Import java.util.*;
2. Class Ro{
3. Object[] testObject(){
4.
5.
6. }
7. }

Which one of the following code fragments inserted at lines 4,5 will not compile?
a.return null; c.Object[] t=ne Object[10]; return t;
b.Object t=new Object(); return t; d.Object[] t=new Integer[10]; return t;
101. Given:
1. public interface Constants{
2. static final int SEASON_SUMMER=1;
3. final int SEASON_SPRING=2;
4. static int SEASON_AUTUMN=3;
5. public static const int SEASON_WINTER=4;
6.}

What will the expected behaviour on compiling the above code?


a.Compilation error occurs at line 2 c.Compilation error occurs at line 4
b.Compilation error occurs at line 3 d.Compilation error occurs at line 5
102. what is output of following program
class YY
{
void m2(Boolean b1)
{
System.out.println("Boolean");}
void m2(boolean b1)
{
System.out.println("boolean");}
}
class Main
{
public static void main(String args[])
{
YY y1=new YY();
y1.m2(true);
}
}

a.Compilation error b.Boolean c.boolean d.Runtime error


103. What will be the output of the following program?
public class Test{
public static void main(String args[]){
Character ch=new Character(„a‟);
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

String s1=”yes”;
System.out.println(ch+s1);
}
}
a) Compilation error b) Runtime error c) ayes d) none of the above
104. class DD{
public static void main(String args[]){
try{
Integer i1=3.3;
double d1=1.2;
System.out.println(i1*d1);
}
catch(Exception e1){
System.out.println(“caught”);
System.out.println(“after try-catch”);
}
}
}
What is the output of above program?
a) 3.599 after try-catch c) Compilation error
b) 3 after try catch d) Runtime error

105. Which of the field declaration is legal within the body of an interface?
a) protected static int answer=42; c) int answer=42;
b)int answer; d) private final static int answer=42;
106. public class Test{
public static void main(String[] args)
{
System.out.println(6^4) ;

}}
What is the output?
a) 1296 b) 24 c) 2 d) Compilation Error
Ans: c) 2
107. What is the role of "RMI" in the "n" tier architecture?
a) RMI will always be the third tier of the architecture
b) RMI can be any tier of the architecture
c) RMI will be used between any 2 tiers for communication
d) all of the above
108. Abstract class is a class which
a) Inherits Abstract Methods/interface but doesn't Implement it
b) Implements Abstract Methods
c) Does not have Abstract methods (but is denoted abstract )
d) Implements an abstract Interface
109. The serialization process can be controlled using the interface
a) Externalizable c) ActionListener
b) Serializable d) Runnable

110. Class C is inherited from class A and class B,class D is inherited from class C; Which of the following
is true?
i> class C inherits class A attributes iii> class D inherits class B attributes only
ii> class C inherits class B attributes iv> class D inherits class A attributes only
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

v> class D inherits class A & class B attributes


a) i, ii, v b)i, ii, iii, iv, v c)ii, iii d)i, iv
111. Will the following class compile? If yes what is the output?
class Envy
{
static int i;
Envy()
{
++i;
}
public static void main(String args[])
{
System.out.println(i);
}
}
a) Yes , it compiles but NullPointerException thrown at runtime
b) Compiler error , System.out.println ( i ) : variable i may not have been initialized
c) Yes it compiles & output = 0
d) Compiler error, ++ i : can't make a nonstatic reference to a static variable, i
112. An abstract class can have static methods that are not abstract.
a) TRUE b) FALSE c) Ignore this choice d) Ignore this choice
113. A programmer wants to develop different types of windows like SpreadSheetWindows, GraphWindows
etc. The contents of the windows need to be redrawn using a function called paint.Which of the
following is the best OO design?
a) A virtual function "paint" is defined in a base class called windows and each derived classes
SpreadSheetWindows, GraphWindows overrides the method paint
b) The operation paint is implemented in the base class windows and SpreadSheetWindows,
GraphWindows are derived from the base classes
c) Code two classes SpreadSheetWindows, GraphWindows which take care of different types of
repainting for different windows
d) A single class called windows and operations called SpreadSheetWindows, GraphWindows,
paintWindows
114. If I create and load all the dialogs (say 50 dialog) in an UI Application at the start up into a dialog array
and show and hide one dialog on a need basis, what do I achieve?
a) Good Performance and Bad Memory usage c) Good Performance and Good Memory usage
b) Bad Performance and Good Memory usage d) Bad Performance and Bad Memory usage
115. The Vector class in Java
a) provides methods for working with c) is Serializable
dynamic(growing) arrays d) all of the above...
b) allows varies element types

116. If one needs to find out what are the methods of one object/class by reading a .class file(without having
.java file) what way/API can help
a) API cannot do this work, you must have a c) Util package has the API to do this
specialized software for this. d) You cannot do this by any way
b) Reflection API can do this

117. Which of the following is correct definition of parameter marshalling?


a) conversion of basic data types to bytes
b) conversion of bytes to basic data types by stub
c) packaging of the parameters to be sent to the remote methods as block of bytes
d) all of the above
118. In java, three tier architecture is usually( in most generic way) implemented using
a) Front end in HTML, middle tier in pure java, odbc in backend
b) Front end in applets, middle tier in beans, odbc in backend
c) Frontend on HTML/Swing, middle tier in Servlets/Beans/EJB and Database server in the backend
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

d) none of the above


119. Which methods of a remote object a client object can call?
a) all methods c) methods registered in rmiregistry
b) Methods defined in remote interface d) none of the above

120. Which of the following tools is used to generate the stubs and skeletons for a remote service?
a) javac b) rmic c) java d) rmiregistry
121. What interface must a class inherit from before an object of that type could be written to a stream?
a) Serializable c) any one of the above
b) Remote d) none of the above

122. What is the main disadvantages of using Java vis-à-vis C/C++ language
a) Interpretation of the program before each execution makes it slow.
b) Objects can be garbage collected resulting in unstability of programs
c) The LOc (lines of code) required for a java program is more when compared to the C/C++ counterpart
d) None of the above
123. Inside the interface, while declaring a function that others can access remotely, you must extend which
interface?
a) Cloneable b) Serializable c) RemoteObject d) Remote
124. What variables are substitute in java for the global variables
a) Instance variables b)static variables c)public variables d)final variables
125. The following code which is saved in c:\test.java. Choose the appropriate statement which will compile
it and do the placement of the bytecode accurately.
package mypackage;
public class test
{
}
a) c:\>javac -d . test.java c) c:\mypackage> javac test.java
b) c:\> javac test.java d) c:\mypackage> javac c:\test.java

126. The capability of an object to exist beyond the execution of the program that created it its indicated by
inherting from
a) Serializable interface c) both of the above
b) Remote interface d) this cannot be achieved without database or a file.

127. Which among the following have elements in insertion order?


a. HashMap b. TreeMap c. sortedMap d. LinkedHashMap
128. Which the following program is correct with the given program?
import java.io.*;
class test{
public static void main(string args[]) throws IOExeception{
InputStreamReader isr=new InputStreamReader(System.in);
BufferReader br=new BufferReader(isr);
String s= br.readLine();}}
a. Compilation error
b. Always throws an exception during runtime
c. Compiles fine and reads one line of input from the keyboard on execution
d. reads one line of input from the keyboard
129. InputStream and OutputStream are
a) concrete classes. b)interfaces. C)abstract classes. d)final classes.
130. Which of the following statements is TRUE?
a) Hashtable does not allow NULL values to be added to it.
b) Insertion and removal of elements is faster in ArrayList than in LinkedList.
c) For searching operations TreeSet is faster than HashSet.
d) Hashtable and HashMap are synchronized.
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

131. Select which of the following is the best place to close the connection in the simple java code
a) try block b) catch block c) finally block d) any of the above

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

VELALAR COLLEGE OF ENGINEERING AND TECHNOLOGY


(Accredited by NAAC with „A‟ Grade & Accredited by NBA)
Thindal, Erode - 638012
(Autonomous)
WIPRO PRP TRAINING
Milestone 2 MCQs
1. Which of the following statement is false about Resultset?
A. Resultset is an object which contains results of executing an SQL statement.
B.Resultset maintains a cursor pointing to its current row of data.
C.ResultSet has nextLine() method to move to the next row of data.
D.Resultset has a set of getXXX() methods to retrieve data from columns.
2. Which of the following Annotations is used to mark if a function is obsolete?
A. @SuppressWarnings B. @Override C. @Depricated D.@Inherited
3. Which of the following is not a wrapper class?
A. String B.Float C.Double D.Integer
4. @Override is an example for
A. Single value Annotation. C. Marker Annotation.
B. Multi value Annotation. D. None of the above.

5. How many methods do you implement if a class implements Serilizable interface?


A.0 B.1 C.2 D.3
6. Which of the following package contains the JDBC API?
a) Java.jdbc.sql b) Jdbc.sql c) Java.sql d) None of the above
7. Which of the following statement is used to turn off auto-commit mode of a connection?(„con‟ is the
connection object)
a) con.setAutoCommit=false; c) con.setAutoCommit(false);
b) con.autoCommit=false; d) con.autoCommit(false);
8. What does the following code do?

PreparedStatementpstmt=con.prepareStatement(“Select* from emp”);


ResultSetrs=pstmt.executeQuery();
While(rs.next()){
System.out.println(rs.getString(1));}
While(rs.next()){
System.out.println(rs.getString(2));}
a) It retrieves all the data from the emp table and print the values of the first column of the table.
b) It retrieves all the data from the emp table and print the values of the second column of the table.
c) It retrieves all the data from the emp table and print the values of the first column of the table and
then all the values in the second column of the table.
d) It will give runtime exception-Exhausted ResultSet.
9. Calling getMetaData() on a connection object returns a object
a) ResultSetMetaData c) StatementMetaData
b) DataBaseMetaData d) DriverMetaData

10. Which of the following is the wrapper class for char data type?
a) java.lang.Char b) java.util.Char c) java.lang.Character d) java.util.Character
11. Junit is
a) a product from Jakarta c) An Opensource testing framework
b) a product from Apache d) None of the above

12. Which of the following method in the ResultSet is used to retrieve date values?
a) getDate(int columnIndex) c) getTime(int columnIndex)
b) getSQLDate(int columnIndex) d) getString(int columnIndex)
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

13. If auto-commit mode has been disabled in a JDBC application ,the SQL statements are grouped into
transactions which must be terminated by calling either or
a) setAutoCommit(true),setAutoCommit(false) c) executeQuery(),executeUpdate()
b) commit(),rollback() d) commit(),close()

14. Upperclass of all the classes representing the output stream of bytes is
a) InputStream b) Writer c) OutputStream d) Reader
15. Term tuple in RDBMS indicates
a) a column in a table c) Pool of values for specific column
b) a row in a table d) No of rows in a table

16. Which of this method is used to read a string from the input stream?
a) int read() c) String readLine()
b) int read() throws IOException d) String readstring() throws IOException
17. Which command is used to drop a view called “v1”?

a) DROP v1 b) DROP VIEWS v1 c) DROP VIEW v1 d) NONE


18. Which of the following statement interface is used for executing select queries?
a) executeQuery() b) execute() c) executeUpdate() d) executeSelect()
19. Which of the following statement if false about callable statement?
A. We use setXXX(parameter value) method to supply values IN parameters of the procedure
B. Once the stored procedure is executed ,we can use getXXX(parameterIndex) to retrieve values.
C. Callable statement is executed only by executecall() statement.
D. Callable statement can be closed by using close() statement.
a) C b) B c) D d) A
20. Which Of The Following Statement Is True?
a) Hashvalues does not allow null values to be added to it.
b) Insertion and removal of elements in araaylist is faster than inlinkerlist
c) For searching operation treeset is faster than hashset.
d) Hashtable and Hashmap are synchronized.
21. Which of the following Statement is false?
a) The start method of the Thread class is used to move a thread from a new State to the runnable
state.
b) It is possible for a thread to move directly from the blocked state to running state.
c) The join method of the thread class accepts a timeout parameter.
d) It is possible to use the synchronized keyword for a block of code.
22. Which Ofthe Following Statement Is not True about collection interface?
a) Set interface extends collection interface
b) All the methods defined in the set interface are also defined in collection interface.
c) List interface extends collection interface.
d) All the methods defined in the list interface are also defined in collection interface.
23. Which of The Following Statement Is True with respected to map?
a) Both the keys and values must be object
b) The keys can be primitive type and the values must be objects.
c) The keys must be objects and the values must be primitive type
d) Both the values and keys must of primitive type
24. Which of the following is used to execute stored procedures from a JDBC program?
a) Statement b) CallableStatement c) PreparedStatement d) None of above
25. All primary keys should be candidate keys
a) True b) False
26. Which of the following is true about set?
a) Hashset cannot have null values c) Set allows null values, but single occurrence
b) Set allows duplicate values d) Set extends the java.utill. collection interface

27. Which of this class contains the method for deserialization object?
a) InputStream b) ObjectInputStream c) OutputStream d) ObjectOutputStream
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

28. Which method should be a non abstract class implementing a runnable interface implement?

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

a) Start b) Run c) Wait d) Runnable


29. select an SELECT statement which will select the employee details in the order of department name
a) SELECT * FROM EMP ORDER BY DPET.DNAME
b) SELECT * FROM EMP, DEPT WHERE EMP DEPTNO = DEPT.DEPTNO ORDER BY
DEPTNO
c) SELECT * FROM EMP, DEPT ORDER BY DEPT.DNAME
d) SELECT * FROM EMP, DEPT WHERE EMP.DEPTNO =DEPT.DEPTNO ORDER BY
DNAME
30. IF deptno + locationid is a composite key in dept tablethen which of the following is correct?
a) Deptno + locationid can be primary key
b) Deptno + locationid can be candidate key
c) Deptno + locationid can never became foreign key in other table
d) Only a and b are correct
31. Which of the following is odd man out
a) Statement b) Connection c) Driver d) DriverManager
32. The default thread model used by most of the web server for servlets is
a) Multithread model c) no thread model
b) single thread model d) process model

33. The synchronized modifier is used to control access to critical code in multithreaded programs.
a) False b) True c) Ignore d) Ignore
34. JNDI is
a) Naming service b) directory interface c) both of the above d) none of the above
35. A head request is just like a get request except that
a) it asks server to return response headers only and not the complete resource.
b) is used to check characteristics of a resource without downloading it
c) is used when you don't need actual file contents
d) all of the above
36. java.io.Serializable is
a) Marker interface in Java
b) contains functionality required for serialization of objects
c) a class containing the serialize function
d) all of the above
37. The process of writing the state of an object to a byte stream, To save the state of your program to a
persistent storage area such as a file is called as . The process of restoring these objects by
using the process of .
a) Serialization, deserialization c) Serialization, Externalization
b) deserialization, Serialization d) none of the above

38. Which of the following type of driver was widely used when JDBC was very new.
a) JDBC-ODBC bridge plus ODBC driver c) JDBC-Net pure Java driver
b) Native-API partly-Java driver d) Native protocol-pure Java driver

39. The JDBC API consists of some classes and some interfaces. Identify which out of the following is/are
class/classes
a) DriverManager b) CallableStatement C) Connection d) All of the above
40. The advantages of RMI are
a) Built in JDK1.3 b) free of cost c) easy to use d) all of the above
41. execute(" ") method of a Statement is used when
a) The query to be executed is dynamic and it is not known whether it is select or update statement.
b) The query to be executed is very complex
c) The query to be executed is not a DML statement
d) None of the above
42. What is the modifier that for a method, so that only one thread can access it at a time, in a multi-threading
context
a) Final b) Synchronized c) Abstract d) Static
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

43. To implement Runnable, a class needs to implement the method

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

a) run() b) CreateThread() c) main() d) None of the above


44. Transient variables can be serialized
a) True b) False c) Ignore this operation d) Ignore this operation
45. Compound names in JNDI are composed of one or more atomic names.
a) True b) False c) Ignore this option d) Ignore this option
46. class E{
Public static void main(String args[]){
Integer i1=new Integer(“24”);
System.out.println(ValueOf(i1));
}}
a) compilation error b) runtime error c) 24 d) None of these
47. Which of the annotation in junit 4.x, does the role of class wide teardown method of previous versions?
a) @Before b) @AfterClass c) @Test d) None of the above
48. In which one of the following java class, is the wait() method defined?
a) System b) Runnable c) Thread d) Object
49. Which predefined feature can be used to print a line in the user environment?
a) PUT_DBMS.OUTPUT c) DBMS_OUTPUT.PUT_LINE
b) OUTLINE.OUTPUT d) OUTPUT.PUTLINE

50. Which of the following is true regarding Type I Driver?


a) It Written in Java c) Does not require per installation
b) It written in Native code d) None of the above

51. Which of the following annotations are used to annotate a test method in Junit?
a) @After b) @AfterClass c) @Before d) None of the above
52. Drop table statement removes
a) Only the rows of the table c) Removes the columns , rows and structure
b) Only the columns of the table definitions
d) None of the choices
Ans : removes the data definition and all data, indexes, triggers, constraints, and permission
specifications for the table
53. All the Junit method should be marked with Annotations
a) @After b) @Test c) @Before d) @BeforeClass
54. Annotation is a feature added in Package of Java
a) java.annotaion b) java.util.annotation c) java.lang.annotation d) None of the above
55. public class MyThread extends Thread{
private int count;
MyThread(){count=1;}
public void run(){
synchronized(count){
count++;
System.out.print(count);
}
}
public static void main(String[] args){
MyThread mt=new MyThread();
mt.start();
}
}
What will be the result of the above code?
a) Prints 1 b) Prints 2 c) Compile-time error d) None of the above
56. Which program declaration is correct for a function?
a) CREATE OR REPLACE FUNCTION tax_amt (p_id NUMBER(10)) RETURN NUMBER
b) CREATE OR REPLACE FUNCTION tax_amt (p_id NUMBER) RETURN NUMBER
c) CREATE OR REPLACE FUNCTION tax_amt (p_id NUMBER, p_amount OUT NUMBER)
d) CREATE OR REPLACE FUNCTION tax_amt (p_id NUMBER()RETURN NUMBER(10,2)
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

57. Which one of the following statement is true?


a) Thread.run() method is used to move a thread from a new state to the runnable state.
b) Thread.runnable() method is used to move a thread from a new state to the runnable state.
c) Thread.start() method is used to move a thread from a new state to the runnable state.
d) Runnable interface declares the start method.
58. class DD{
public static void main(String args[]){
try{
String s1=”tech”;
double d1=Double.toString(“1.55”); \\double d1=Double.parseDouble("1.55"); is correct
System.out.println(s1+d1);
}
catch(Exception e1)
{System.out.println(“caught”);}
System.out.println(“after try-catch”);
}
}
What is output of above program?
a) tech1.55 after try-catch c) Compilation error
b) tech+1.55 after try-catch d) caught after try-catch

59. Super class of all classes representing an input stream of characters is ------------
a) InputStream b) Writer. c) Reader d) OutputStream
Explanation: This abstract class is the super class of all classes representing an input stream of bytes.
60. Super class of all classes representing an output stream of characters is ------------
a) InputStream. b) Writer c) Reader d) OutputStream
Explanation: This abstract class is the super class of all classes representing an output stream of bytes.
61. What can be one of the possible output?
public class TestRunnable implements Runnable{
public static void main(String args[]) throws Exception{
Thread t1=new Thread(new TestRunnable());
T1.start();
System.out.print(“Start”);
T1.join();
System.out.print(“End”);
}
public void run(){
for(int i=0;i<3;i++){
System.out.print(i);}
}}
a) An Exception is thrown at runtime. c) The code Executes and prints “SartEnd012”.
b) The code Executes and prints “SartEnd”. d) The code Executes and prints “Sart012End”.

62. With respect to the program given below,which of the following is correct?
import java.io.*;
class Test{
public static void main(String args[]){
InputStreamReaderisr=new InputStreamReader(System.in);
BufferedReaderbr=new BufferedReader(isr);
String s=br.readLine();
}}
a) Compilation error might occur as the checked exception is not handled
b) Might throw a runtime exception.
c) Compiles and reads one line of input from the console.
d) Reads one line at a time till we press „q‟.
63. Which of the following are true regarding the JDBC-ODBC Bridge driver
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

a) provides a pure java based solution for connecting to databases.


b) You have to install ODBC drivers on every system that you want to use.
c) ODBC driver is provided as a part of JDK.
d) It is a Type-II driver.
Ans: b (The ODBC driver needs to be installed on the client machine.)
64. A PL/SQL stored procedure cannot be invoked from
a) PROCEDURE c) FUNCTION
b) Anonymous PL/SQL Block d) SELECTION statement

65. Is the following command right? UPDATE EMP SET ENAME="JACK" WHERE EMPNG=7788
a) True b) False
66. Foreign key is
a) Key which references column in same table. c) Is always unique
b) Key which references column from other table d) Both A and B

A foreign key is a field (or collection of fields) in one table that uniquely identifies a row of another table
or the same table, a foreign key is a field (or collection of fields) in one table that uniquely identifies a row
of another table or the same table.
67. In which mode Formal parameter acts as a constant?
a)IN b) OUT c) IN OUT d) OUT IN
Answer: a Default mode& Formal parameter acts like a constant
68. A(n) contains a subset of the conceptual view, relevant to a particular group of users.
a)Physical view b)E-R model c)External view d)internal view
69. Say true or false?In Junit 4.x the java class which we are testing should extends from TestCase class?
a)Trueb)False
70. A parameter with OUT mode needs to be passed as a when the concerned procedure is invoked.
a)Value b)Variable c)Variable or Value d)None of the choices
71. public class Demo implements Runnable{
public static void main(String args[]){
Thread t7=new Thread(new Demo());
t7.start();
System.out.print("Vehicle");
try{
t7.join();
}catch(InterruptedException e){
System.out.print("InterruptedException");
}
System.out.print("Bus");
}
public void run(){
for(int index=7;index>3;index--){
System.out.print(index);}}}
What will be the output?
a) Compilation fails c) The code executes and prints”VechicleBus7654”.
b) An exception is thrown at runtime d) The code executes &prints”Vechicle7654Bus”
72. Given the following:
publicclass p1 implementsRunnable{

publicstaticvoidmain(String args[])throws Exception{


Thread t6=newThread(new p1());
t6.start();
System.out.println("fruit");
t6.join();
System.out.println("apple");
}
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

publicvoidrun(){
intarray[]={4,5,6};
for(int element :array)
System.out.println(element);
}}
a) The code execute and prints “fruit456apple” c) Compilation error.
b) The code execute and prints “fruitapple456” d) Run time exception
73. How would you restart a dead thread?
a) you cannot restart. c) By calling the Run() method
b) By calling the start() method d) By calling the restart() method
74. Disadvantage of file processing system include
a) Reduced data dependence c) Limited data by storing
b) Program dependent data d) Both b and c.
75. the following code snippet is an example of
@twizzle
Public void toggle(){}
Public @interface twizzle{}
a) Marker annotation c) Multi value annotation
b) Single value annotation d) None of the above

76. Streams are classified as and Streams


a) Character and byte c) Bit And byte
b) Bit and word d) Character and word
77. Given :
publicclass p1 extendsThread{
privatestaticintvalue=37;
publicvoidrun(){
value++;
System.out.print(value);
}
publicstaticvoid main(String args[]){
value++;
p1 t10=new p1();
t10.start();
}}

What is the result of computing and executing the above code ?


a) Prints 37 b) Prints 38 c) Prints 39
d) Compile time error in line where start() method is invoked
78. In relational model parent child relationship is
a) one to one b) one to many c) many to many d) many to one
79. Procedures are compiled every time it is executed
a) True b) False
80. Which of the following is not a valid state of a thread?
a) Terminated b) altered c) Blocked d) Runnable
81. When a thread object is created and start method is invoked on that, which is the initial state it will go
into?
a) running state b) runnable state c) not runnable state d) inactive state
82. Which of the following SQL statement can be used to execute a pre-compiled SQL statement
a) Statement b) Prepared statement c) Callable statement d) None of the above
83. Junit is a framework
a) Intergation testing b) Functional testing c) Acceptance testing d) Unit testing
84. A key is termed as primary key when
a) it is unique c) both unique and not null
b) it is not null d) primary key is independent of these concepts

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

85. Given the following:


classMyRunnableimplementsRunnable{
publicvoidrun(){
System.out.println(Thread.currentThread().getName());
}
}
publicclass p1{
publicstaticvoidmain(String[] args){
Thread mt=newThread(newMyRunnable(),"MyThread");
mt.run();
}
}
What will be the output on the console?
a) MyThread b) main c) MyThread main d) No output
86. Command used to drop function named cal_pct
a) Drop cal_pct function; c) Drop cal_pct;
b) Drop function cal_pct; d) cannot Drop functions

87. How many Joining conditions are needed to join 10 tables?


a)1 b)5 c)9 d)10
88. In a Salesperson table following are non null columns. which column can be selected as primary key
a) Salesperson_id b) Salesperson_Name c) Salesperson_city d)Commission
89. Which one of these events will cause a thread to die?
a)On calling the sleep() method c) When the execution of the start() methods ends
b)Oncalling the wait() method d) When the execution of the run() methods ends

90. In Junit, it is possible to ignore a test method from testing?


a)True b)False
91. is a collection of logically related data at one place
a) Database c) Database Management System
b) Data d) Computer Based information System
92. Which statement about function is true?
a) A function must have a return statement in its booted
b) Function can be stored in client-side application

c) Function information is stored in both client-side and server-side


d) Function cannot be used as part of SQL expression
93. Term Degree in RDBMS indicates
a)the no.of Attributes b)the no.of rows in a table c)a Column in table d)a Row in a table
94. class MyRunnable implements Runnable {public void run() {}}
public class ThreadTest{
public static void main(String args[]){
1. Thread t1=new Thread();
2. Thread t2=new Thread(new MyRunnable());
3. Thread t3=new Thread(new Runnable());
4. Thread t4=new Thread(“Thread”);
}}
At which line is compile-time error generated?
a) Line 1 b) Line 2 c) Line 3 d) Line 4
95. Which of the following method require that a lock be held on the object instance on which the method is
invoked?
a) Notify b) Start c) Join d) Yield
96. Which of the following is responsible for managing all the JDBC drivers?
a) Connection b) Statement c) DriverManager d) ResultSet
97. Procedures can be invoked with zero or more input parameters.
a) True b) False
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

98. Using JDBC, we can send

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

a) sql statements to the database c) Both sql and pl/sql statements to the database
b) pl/sql statements to the database d) None of the above
99. Threading in Java can be implemented by
a) Subclassing Thread and overriding "run" c) Either a or b
b) Implementing "Runnable" Interface d) None of the above
100. Thread are synchronized by
a) sleep and wakeup c) synchronize and desynchronize
b) wait and notify d) sleep and notify
101. Which of the following is true about DSN

a) It's a data source name used to identify which database is to connectedfrom the program
b) created using control panel of windows OS and hence platform dependant
c) created while using JdbcOdbc bridge driver from the java program
d) all of the above.
102. In Java, when two or more threads need access to a shared resource, is a way to ensure that the
resource will be used by only one thread at a time.
a) creating a semaphore c) Synchronization
b) Using mutex d) none of the above.

103. The Synchronized keyword is used in Java to implement the concept of


a) Thread Priority c) Both of the above
b) Thread Running d) None of the above
104. To implement JDBC in your program, you must import

a) java.awt package b) java.applet package c) java.sql package d) java.net package


105. You can set a thread's priority
a) when you first create the thread c) both a and b
b) at any time after you create the thread d) Priority cannot be changed at all
106. What is the output of following program?
class YY {
void m1(Integer i1) {
System.out.println("integer:"+i1.intValue());}
void m1(int i1) {
System.out.println(i1);}

}
class p1 {
public static void main(String args[]) {
YY y1=new YY();
Y1.m1(3);
}}
a) 3 b) Integer:3 c) Compilation error d) Runtime error
107. The default ResultSet object moves only in the forward direction.
a.True b.False
108. Given the following
class RunOne implements Runnable{
public void run(){
System.out.println(Thread.currentThread().getName());
}
}
public class p1{
public static void main(String args[])
{
Thread t1=new Thread(new RunOne(),"ThreadOne");
t1.run();
}}
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

What will be the output on the console?


a.ThreadOne

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

b.main
c.ThreadOne
main
d.No output
109. class DD{
public static void main(String rg[]){
try{
Integer i1=3.3;
double d1=1.2;
System.out.println(i1*d1);
}
System.out.println(“after try-catch”);
}}
What is output of above program?
a.3.599 after try-catch c.Compilation error
b.3 after try-catch d.Runtime Error

110. The following statement is issued against the oracle database:


create view EMP_VIEW_01
as select E.EMPID,E.LASTNAME,E.FIRSTNAME,A.ADDRESS
from EMPLOYEE E,EMPL_ADDRESS A
where E.EMPID=A.EMPID
with check option;
Which line will produce an error?
a) from EMPLOYEE E,EMPL_ADDRESS A c) where E.EMPID=A.EMPID
b) create view EMP_VIEW_01 d) This statement contains no errors

111. Which of the annotation in Junit 4.x,does the role of classwide setup method of previous versions?
a) @Before b) @BeforeClass c) @Test d) none of the above
112. Which one statement below is true concerning the following code?
class MyRunnable extends Object implements Runnable{
public void run(String message){
System.out.println(“in space run method:”+message);
}}
Public class TestThread{
Public static void main(String args[]){
MyRunnablemr=new MyRunnable();
Thread mt=new Thread(mr);
mt.start();
}}
a) The code will compile completely and will execute without throwing any exception.
b) There will be a complier error because the class MyRunnabledoesnot compile correctly.
c) There will be a compiler error at line 9,because the parameter passed to Thread proper type.
d) The code will compile correctly but will cause run time error on executing the line 10.
113. State which of the following statement is true.
a) The process of executing a synchronized method requires the thread to acquire a lock.
b) Any overriding method of a synchronized method is implicitly synchronized.
c) If any method in a class is synchronized, then the class itself must also be declared using the
synchronized modifier.
d) If a thread invokes a static synchronized method on an instance of class A, then the thread must
acquire the lock of that instance of class A.
114. In which of the package is the Wrapper classes found?
a) java.lang b) java.util c) java.io d) java.sql
115. An application view known as TRANS_HIST_V IS no longer needed. Which SQL statement should you
use to remove the view?

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

a)DROPtrans_hist_v b)DELETE trans_hist_v c)DROP VIEW trans_hist_v d)TRUNCATE VIEW


trans_hist_v
116. Which one of the following method does not accept a timeout?
a)join b)sleep c)wait d)start
117. assertEquals() of junit 4.x doesn‟t use autoboxing
a)true b)false
118. When you seta auto-commit false then SQL statement will be executed only when you call
a)commit() b)rollback() C)save() d)none of these
119. Which of the following are the benefits of database approach:
A:Redundancy is reduced E:Security is applied
B:Inconsistency is avoided F:Integrity is maintained
C:Data is shared G:Data independency is provided
D:Standard is enforced

a) All the above b) A,B,C,D,E,G c) A,B,C,E,F,G d) A,B,C,D,E,F


120. What will be the result of compiling and running the following code?
publicclass p1 implementsRunnable{
Boolean flag=true;
publicvoidstart(){
if(flag)
System.out.println("Hello World");
}
publicstaticvoidmain(String[] args){
p1 t=new p1();
t.start();
}}
a) Compilation succeeds,Hello World c) Compilation fails
b) Compilation succeeds,nothing is d) Runtime error occurs

121. By default,a JDBC Connection is in an autocommit mode


a) True b) False
122. Term cardinality in RDBMS indicates
a) the number of attributes c) a column in table
b) the number of rows in table d) a row in table

123. select an erroneous column name in oracle from the following


a) Annual_Salary c) Tax_60#09$
b) Roll# d) _valid_status
124. when the following piece of code is executed,
ResulSetrs=stml.executeQuery(“select*from emp”);
rs.next();
the ResultSet cursor will be pointing to _
a) the first row of resultset c) It cannot be defined
b) the second row of resultset d) None of the above

125. which of the following JDBC driver works in a 3 tier architecture?


a) Type I driver c) Type IIIdriver
b) Type II driver d) Type IV driver
126. Alternate key is
a) columns with only not null constraints c) candidate key but not chosen as primary key
b) columns with only unique constraints d) None of the above

127. conversion from primitive type to wrapper type is known as


a)unboxing b)autoboxing c)boxing d)none of the above
128. we can create our own user defined annotations
a)true b)false
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

129. classThreadExextendsThread{
publicvoidrun(){
System.out.println("ThreadEx");

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

} }
publicclass p1{
publicstaticvoidmain(String args[]) {
ThreadExTex=newThreadEx();
Tex.start();
Tex.start();
} }
What is the result of attempting to compile and run the program?
a) The program compiles and runs without error
b) The second attempt to start thread ThreadEx is successful
c) Compile-time error
d) It prints ThreadEx and a runtime exception is thrown after that
130. Which of the following are optional parameters of Junit @Test annotation?
a. expected c. Both expected and timeout
b. timeout d. None of the above

131. The PL/SQL function body must have at least ................ RETURN statement(s)
a)0 b)1 c)2 d)many
132. float f=new Float(2.5);
Above line is example of
a)Unboxing b)AutoBoxing c)Boxing d)None of the above
133. After COMMIT,allsavepoints are saved
a)true b)false
134. Benefits of PL/SQL
a)Portability b)Exception Handling c)Modularization d)All the above
135. External View is
a) individual user view c) Storage view
b) Community user view d) None of the above
136. Which program declaration is correct for a procedure?

a) CREATE OR REPLACE PROCEDURE Project(p_id NUMBER)RETURN NUMBER


b) CREATE OR REPLACE PROCEDURE Project(p_id NUMBER)RETURN NUMBER(10,2)
c) CREATE OR REPLACE PROCEDURE Project(p_id NUMBER,P_amount OUT NUMBER(10,2))
d) CREATE OR REPLACE PROCEDURE Project(p_id NUMBER)
137. What will happen to the following test?Will it fail or pass?
@Test(timeout=100)
public void infinity(){
while(true);
}
a)Pass b)Fail
138. Entity integrity is ensured by
a) primary key concept c) check constraint
b) foreign key concept d) none of the above

139. what will be the result of compiling and running the following code?
public class p1{
public static void main(String argv[]){
Thread1 Thread1=new Thread1();
Thread2 Thread2=new Thread2();
Thread1.start();
Thread2.start();
System.out.println("In main");
}
}
class Thread1 extends Thread{
public void run(){
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

System.out.println("In Thread1");

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

}
}
class Thread2 extends Thread{
public void run(){
System.out.println("In Thread2");
}
}
a) The code will not compile
b) The code will compile and print the following messages in the order given as in main
In Thread1
In Thread2
c) The code will compile correctly and print the following message in the order given as
In Thread2
In Thread1
In main
d) The code will compile and print the following messages in any random order
In Thread1
In Thread2
In main
140. what is the output of the following program
class p1{
publicstaticvoidmain(String a[]){
Double d=new Double("wipro");
System.out.println(d.doubleValue());
}
}
a) Compilation error c) Throws InputMismatchException at runtime
b) ThrowsNumberFormatException at runtime d)0

141. Commit() and RollBack() are methods belonging to which of the following classes?
a) Driver b) Connection c) Statement d) ResultSet
142. The process of ensuring that any shared resource is accessed by a single thread at a time is called as
a) Multi-threading b) Synchronization c) Cloning d) Serialization
143. What will happen if the code below is executed?
Assume that Dept table exists and is empty
import java.sql.*;
class JDBCDemo{
public static void main(String[] args) {
String url = "jdbc:oracle:thin:@192.168.121.13:1521:enr";
String user = "scott";
String password = "tiger";
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection(url,user,password);
String sqlInsert = "INSERT INTO DEPT VALUES" +
"( 12 , 'WENA', 'BLR')";
Statement si = con.createStatement();
int rowsInserted = si.executeUpdate(sqlInsert);
con.rollback();
con.close();
}
catch (Exception e) {
System.err.println("Error!!");
}
}

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

}
a) One row will be inserted and committed
b) One row will be inserted and then will be rolledback when program terminates normally
c) Insertion will not happen
d) Will throw an error because executeUpdate() method cannot be used for inserts
144. In case an error occurs in the execution of a Oracle stored procedure from a Java program
a) SQLException is thrown and the oracle error code returned
b) SQLException is thrown and the JDBC error code is returned
c) IOException is generated as the database connection is lost
d) No exception is returned but the program hangs
145. You can make an object that reads and writes records from a database safe for multiple clients by
a) declaring its methods to be synchronized
b) declaring the method as throwing a RemoteException
c) implementing the remote interface
d) closing the file on finalize()
146. Usually, Server Socket waits on a port for requests, and upon receiving a request, gives a socket
connection on the
a) same port c) a port number which matches that on the client end
b) different port d) None of the above
147. Socket communication is an example of

a) Connectionless b) Connection oriented c) Either 1 or 2 d) Neither


148. Invoking Start on a Thread instance starts a new
a) derived class of Thread class
b) separately scheduled thread in the Java Virtual Machine, which then executes the code specified
in the run method of that Thread subclass
c) separately scheduled thread in the operating system, which then executes the code specified in the run
method of that Thread subclass.
d) separately scheduled thread in the Java Virtual Machine, which then executes the code specified in the
start() method of that Thread subclass
149. For writing transactions, the Autocommit mode of the Connection object should be made as true
a) True b) False c) Ignore this option d) Ignore this option
150. Statement stmt = con.createStatement();
String s = "INSERT INTO COFFEE " + "VALUES('Frensh_Roast', 49, 8.99, 0, 0)";
what will be the next statement
a) executeQuery() b) executeUpdate() c) execute() d) getResultSet()
151. getLocalPort() method of ServerSocket class will give
a) port on which Server socket is created.
b) port on which client socket is created on the server machine.
c) port on which client socket is created on client machine.
d) none of the above
152. If I want to use JDBC code in my Java program what all I need to do
a) Include the jdbc class files in the CLASSPATH and import the relevant packages in the
program
b) Just have the jdbc class files in the CLASSPATH and run the java program with the classpath option
c) Just import the relevant JDBC packages in the program
d) Both 1 and 2
153. 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();
}
public void start() {
for (int i = 0; i<10;i++)

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

System.out.println("Value of i =" +i);


}
}
a) A compile time error indicating that no run method is defined for the Thread class
b) A run time error indicating that no run method is defined for the Thread class
c) the programs compiles and runs correctly with values 0 to 9 printed out
d) No output in the run time
154. If there are two threads with different priority, does that mean that higher-priority thread will run faster
than the lower priority thread
a) True b) False c) Ignore this option d) Ignore this option
155. If a thread has entered a synchronized method of an instance, another thread cannot call any other
methods (synchronized or non-synchronized) of the same instance.
a) True b) False c) Ignore this option d) Ignore this option
156. A thread's run() method includes the following lines:
1. try{
2. sleep(100);
3. } catch(InterruptedException e) { }
Assuming the thread is not interrupted, which one of the following statements is correct?
a) The code will not compile, because exceptions may not be caught in a threads run() method.
b) At line 2, the thread will stop running. Execution will resume in atmost 100 milliseconds
c) At line 2, the thread will stop running. Execution will resume in exactly 100 milliseconds
d) At line 2, the thread will stop running. Execution will resume in some time after 100 milliseconds
have elapsed.
157. Which of the following class can be used to find out the ipaddress of your machine?
a) IpAddress b) InetAddress c) NetAddress d) none of the above.
158. Which one of the following object contains the description of the current resultset.
a) ResultSet Object. c) ResultSetMetaData Object
b) MetaData Object. d) None of the above
159. In JNDI the context object contains

a) Common information like protocol, ipaddress which is required forlooking up most of the remote
objects in one project
b) Common information like the object name, which is required for looking up each of the remote
objects in one project
c) Specific information like unique name required for each lookup
d) none of the above
160. We can synchronize
[i] block [ii] method [iii] object [iv] class
a) only [ii] b) [ii], [iii] c) [i], [ii], [iii], [iv] d) none of the above
161. Choose best answer for the following questionNaming.rebind method
a) re-registers the same remote object again in the rmiregistry
b) registers the remote object in rmiregistry with the unique namegiven as parameter to this method.
c) removes the registration of the remote object which is already registered with the unique name given
as parameter to this method.
d) both c and b
162. Why are programs needed on Server-side?
a) Dynamic Content generation c) Transactions
b) Database access d) All of the above
163. sql code finally gets converted to JDBC code.

a) True b) False c) Ignore this option d) Ignore this option


164. class WhatHappens implements Runnable
{ public static void main(String[] args)
{ ThreadtThrd = new Thread (this);
tThrd.start();}
public void run(){
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

System.out.println("hi");
}
}
a) This program compiles and word ""hi"" appears in the standard output (once).
b) This program compiles and word ""hi"" appears continuously in the standard output until the user hits
Ctrl+C to stop the program."
c) compilation error
d) runtime error
165. The lowest level synchronization which synchronizes the smallest unit is
a) synchronizing a method c) synchronizing a block
b) synchronizing a object d) synchronizing a class

166. Which one of the following interface is used to call a stored procedure from java
a) StoredCall b) CallProcedure c) CallableStatement d) None of the above
167. From OO point of view which of the following is better for creating a thread
a) Instantiate Thread class c) extend from Runnable
b) extend from Thread class d) implement Runnable

168. translates the standard JDBC calls into the specific calls required by the database it supports.
a) JVM b) Drivermanager c) Driver d) none of the above
169. If we have not created a DSN for the database, it is possible to access this database from Java?
a) Yes b) No
170. Select the odd man out
a) DCOM b) EJB c) CORBA objects d) JNDI
171. Whenever user issues insert,update or delete statement on the table Oracle implicitly locks the table in
a) Row share mode c) share row exclusive mode
b) Row Exclusive mode d) No lock occurs implicitly.

172. Which one of the following is true with Object Types in Oracle?
a) Once the object is created we cannot modify the attributes and methods of a type
b) Once the object is created we cannot modify the attributes of a type but we can modify the
methods of a type using alter type command.
c) we can modify the attributes and methods of a type even if objects are created. .
d) we can modify the attributes but we cannot modify the methods of a type once the object is created.
173. Which of the following situation in a PL/SQL block leads to too_many_rowsexception.
a) When any of the DML statement fetches more than one row from the table
b) when select statement fetches more than one row from the table
c) when select statement fetches more than one row from the table or cannot fetch any row from the table.
d) a and c
174. Unique Index is implicitly created by oracle
a) whenever primary key constraint is imposed on a table column.
b) whenever unique key constraint is imposed on a table column.
c) both a) and b)
d) Oracle does not create unique index implicitly.
175. Raise_application_error can have error code ranging from
a)-20000 to -20999 ** c) any integer number
b)20000 to 20999 d) Only positive integer number
176. PGA is created
a) whenever Oracle instance is created c) at the mount stage of oracle database
b) whenever a user is connected to the oracle d) none of the above
database
177. Each user has a separate SGA in the Oracle Server.

a) TRUE b)FALSE
178. I want to store Employee number , Employee Photograph and Employee description (having data
in MB's) in a table. Which of the following description is invalid
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

a) empno number(4),Photo LONGRAW, emp_descri CLOB


b) empno number(4),Photo LONGRAW, emp_descri LONG

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

c) empnonumber(4),Photo BLOB, emp_descri CLOB


d)empnonumber(4),Photo BLOB, emp_descri LONG
179. What will be the output of the following program
Set Serveroutput on;
declare
X number := NULL;
Y number := NULL;
begin
if X=Y then
dbms_output.put_line('Both are equal');
elsif X<>Y then
dbms_output.put_line('Both are unequal');
else
dbms_output.put_line('Unknown result');
end if;
end;
a) Both are equal c) Unknown result
b) Both are unequal d) Oracle throws the error message

ORA-02258 duplicate or conflicting NULL and/or NOT NULL specifications


180. Which of the following statement(s) is true about triggers
a) Trigger can be associated with a specific database table
b) Row level triggers have access to the :new and :old records
c) Triggers are fired automatically
d) All of the above
181. Following is the sequence of queries executed via SQL PLUS on an ORACLE 8i database.
(i) SET AUTOCOMMIT OFF;
(ii) CREATE TABLE COUNTS (COL1 NUMBER);
(iii) INSERT INTO COUNTS VALUES (5);
(iv) ALTER TABLE COUNTS ADD (COL2 NUMBER);
(v) ROLLBACK;
(vi) COMMIT;
After executing the above statements in order, which of the following statement is true
a) After step (vi), the table COUNTS will have only COL1 and the value will be NULL
b) After step (vi), the table COUNTS will have only COL1 and the value will be 5
c) After step (vi), the table COUNTS will have NULL in both COL1 and COL2
d) After step (vi), the table COUNTS will have value „5‟ in COL1 and NULL in COL2
182. What will be the output of the following statement
select last_day(sysdate) from dual;
a) Current day c) Last day of the current month
b) Last day of the current week d) Last day of the current year

183. Which one of the below list is not a SQL *plus command
a) SPOOL b) STOP c) EXIT d) SAVE
184. Which of the following statement is false
a) PL/SQL table consists of homogeneous c) PL/SQL table is a multi-dimensional table
elements d) None of the above
b) PL/SQL table is indexed by integers
185. Which of the following stores character data

a) CLOB b) BLOB c) BFILE d) None of the above


186. Consider table Temp1(B NUMBER(6),C NUMBER(6))
Values for B and C
BC
66
77
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

88

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

What is the output of: select rownum from Temp1 order by B desc;
a) 6 7 8 b) 8 7 6 c) 1 2 3 d) 3 2 1
187. Maximum what size of binary data can be stored in BLOB datatype?
a) 1 GB b) 2 MB c) 4 MB d) 4 GB
188. The memory structure that does not constitute the ORACLE instance is
a) System global Area b) Dictionary Cache c) Redo Log Buffer d) None Of these
189. Primary key is implicitly indexed
a) TRUE b) FALSE
190. Indexing
a) Speedens Inserts c) Reduces space requirements
b) Speedens updates d) Increases space requirements

191. if checkpoint is not enabled which of the following process does the job of a checkpoint.
a) DBWR b) LGWR c) SMON d) PMON
192. Which of the following statement is true?
a) An extent consists of contiguous data blocks c) A data block is the smallest unit of I/O used by
b) A segment may not consist of contiguous data the database.
blocks. d) All of the above

193. Oracle SELECT Query Performance can be enhanced by:


a) Indexes b) Clusters c) Both a and b d) None of the above
194. Stored Procedure cannot be called from :
a) DatabaseTrigger b) Stored procedure c) Function d) None of the above
195. What kind of objects can you place in a Oracle package
a) Procedures b) Functions c) Both a and b d) None of the above
196. When one user is waiting for data locked by another user, the situation is known as .
a) dirty read b) phantom record c) deadlock d) None of the above
197. Which of the following statement is true?
a) A table in Oracle 8i can have multiple LOB columns
b) A table in Oracle 8i can have only one LONG column
c) A table in Oracle 8i can have only one LOB column
d) Both a and b
198. Which of the following query returns the current date
a) select sysdate from dual where rownum = 0; c) select sysdate from dual where rownum< 1;
b) select sysdate from dual where rownum = 1; d) select sysdate from dual where rownum> 1;

199. An object table is a special kind of table that holds objects and provides a relational view of the attributes
of those objects
a) True ** b) False
200. Which Static data dictionary view describes the columns of tables, views and clusters owned by the
current user?
a) COLS c) USER_TAB_COLUMNS
b) USER_COLL_TYPES d) USER_IND_COLUMNS

201. How do you drop a user (say Anil) from the database with all the objects/resources owned by him?
a) DROP USER ANIL
b) DROP USER ANIL CASCADE
c) First drop all the objects/resources individually owned by ANIL and then use „DROP USER ANIL‟
d) Both options (b) and (c)
202. A Join condition involving an operator other than the equivalency is called
a) Non EquiJoin b) EquiJoin c) OuterJoin d) Inner Join
203. When an Oracle Database is started, memory is set aside and one or more processes are started in that
memory, and that memory is called as System Global Area(SGA)
a) True b) False
204. Which of the following are background processes in an oracle instance?
a) DataBaseWriter(DBWR) b) Log Writer(LGWR)
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

205. EMPLOYEE table has the following data c) System Monitor(SMON)


d) All the above

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

EMP_ID EMP_SALARY EMP_COMM

8723 1230 200


4357 2390 null
9823 2000 100
2737 2030 120
What is the result of the following expression
select sum(EMP_SALARY)+sum(EMP_COMM) from EMPLOYEE
a) NULL b) 8070 c) 420 d) 7650
206. When a transaction reads an uncommitted data of other transaction, this will lead to
a) Phantom read b) Dirty read c) Lost update d) None of the above
207. A foreign key whose values are required to match the values of candidate key in the same table are called
a) composite keys b) self referencing keys c) overlapping keys d) none of the above
208. Choose the correct answers to SELECT the list of values in column COL1 from 1 to 3 from a table X (
the table contains values like 1.2,2.3 etc.)
a) select COL1 from X where COL1 between 1 and 3
b) select COL1 from X where COL1 > 1 and COL1 < 3
c) select COL1 from X where COL1 in (1,2,3)
d) select COL1 from X where COL1 not <= 1 and not >= 3
209. :new and :old cannot be used with statement level triggers in Oracle
a)True b)False
210. In Oracle One control file is associated with only one database.
a)true b)false
211. Can the function MAX be used on columns having DataType as Char?
a)TRUE b)FALSE
212. Assume you have a Database Table, which is used for storing historical Data. This table mostof the time is
used for reading data from it and generating reports. Will higher level of Normalization ( > 2 NF) would
necessarily lead to better retrieval of the data contained in the table?
a)YES b)No
213. Indexes are mandatory to be created for every table.
a)True b)False
214. which of the following is an aggregate function
a) SUM b)ORDER BY c)HAVING d)ASC
215. Which of the following options is correct?
a)All types of views are updatable views
b) A view is actually a stored query that is executed whenever it is referred in a SQL command.
c) A view cannot be created as a join on two or more tables
d) Views are updatable even when it uses aggregate functions
216. RDBMS is based upon
a) Predicate logic c) Object Oriented paradigm
b) Relational Set theory d) Graph theory

217. CREATE PROCEDURE TEMP ( A IN NUMBER, B OUT NUMBER) AS


BEGIN
BEGIN
A:=1;
B:=2;
END;
dbms_output.put_line('A'||'A');
dbms_output.put_line('B'||'B');
END;
What are the values of A & B that will be displayed?
a) 1 and 2 b) A is blank and B is 2 c) A is 1 and B is blank d) Gives Error
218. The output of the following query is:
SELECT to_date('25-SEP-2002','mm/dd/yyyy') FROM dual;

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

a) 09/25/2002 b) 9/25/2002 c) 25/9/2002 d) Gives Error


219. Why are smaller size database transactions preferred as a design?
a) Because it is easy to maintain
b) Because the performance is better
c) Because there are less chance of hangs because of shortage of rollback segments
d) Because partial failure in the longer ones would result in inconsistent results
220. A view gets updated automatically when a table gets updated in Oracle.
a) True b) False
221. A table can contain more than one column having LONG data type
a) True b) False
222. The database object that is used to provide improved performance in the retrieval of rows from a table is
a) Synonym b) Index c) Sequence d) Trigger
223. If there is no exception handler for the raised exception in the current block then
1]The exception propagates to the enclosing block
2]If there is no enclosing block then it propagates to the environmentfrom where the PL/SQL block is
invoked
a) only 1 is true b) only 2 is true c) both 1 & 2 are true d) both 1 & 2 are false
224. Consider the following PL/SQL block of code:
DECLARE
ex1 EXCEPTION;
...
BEGIN
...
DECLARE
...
...
BEGIN
...
RAISE ex1;
...
EXCEPTION
WHEN ex1 THEN
...
END;
...
...
EXCEPTION
...
...
END;
Supposed ex1 is raised, and handled. Then,
a) Execution will resume in the inner block from the statement after the error-causing statement
b) Execution will resume from the next executable statement after the end of the inner block
c) The entire program execution will terminate
d) Control is transferred to the exception section of the enclosing outer block
225. declare
v_resultboolean;
begin
delete from sales where sales_idin(15,25,35);
v_result:=SQL%ISOPEN;
commit;
end;
what will be the the value of v_result if 3 rows are deleted ?
a) 0 b) 3 c) true d) false

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

226. Consider the following situation:


Transaction1 has UPDATED row1 of table1 but has not committed as yet
Transaction 2 wants to read(SELECT) the same row
Which of the following statements is correct:
a) Transaction 2 will be asked to wait till Transaction 1 releases the lock on row1
b) Transaction 2 will be given an implicit Shared lock before it could SELECT row1
c) Transaction 2 will be allowed to SELECT row1 reflecting values which is a result of the current
update done by Transaction 1
d) Transaction 2 will be allowed to SELECT row1 reflecting values which is aresult of some
previous committed Transaction from the rollback segment.
227. The data dictionary view which maintains the constraints imposed on the objects created by a user:
a) constraints_users b) constraint_name c) users_constraint d) user_constraints
228. What is the error in the following code?
DECLARE
CURSOR empCursor IS
SELECT Empno, Ename FROM Emp;
BEGIN
FOR empCurRec IN empCursor LOOP
dbms_output.put_line(empCurRec.EmpNo);
END LOOP;
END;
a) Cursor is neither open nor closed, so there will be compilation error
b) There is no Fetching operation, so no record will be fetched, but the code will compile.
c) NO_DATA_FOUND Exception will be raised.
d) There is no error in the code. It will fetch all the records from the table and display the empnos.
229. With respect to execution of the DDL commands in PL/SQL, which one of the following is true?
a) You can execute DDL with EXECUTE IMMEDIATE syntax
b) You can execute DDL with EXECUTE DDL syntax
c) You can execute DDL with DYNAMIC EXECUTE syntax
d) You cannot use DDL in PL/SQL
230. Assume that there is a table called EMP with following columns - EMPNO, ENAME, ESAL without any
primary key. What will be output if we execute the following SQL statement 5 times-
Insert into EMP(EMPNO,ENAME,ESAL) values (NULL, NULL)
a) The Query will return a error and won‟t execute
b) Only 1 record will be inserted with NULL stored in all the columns
c) Only 1 record is created and the system assigns some unique value to the EMPNO column
automatically
d) None of the above
231. Indexing is needed for
a) Faster insertion of data c) Faster retrieval of data
b) Faster updation of data d) Both a & b
232. Consider the statements below
I] IMS conforms to the Hierarchical model
II] IDMS confirms to Network model
III] DB2 confirms to Relational Model
a) Only III is true c) Only II and III are true
b) Only I and III are true d) I, II,III are true
233. All candidate keys except primary key are foreign keys
a) True c) May be true in some cases
b) False d) May be true if primary key is a composite key

234. Select Min(Sal) from emp where sal>(Select min(sal) from empwhere sal> (select min(sal) from emp))
a) ERROR c) Displays Third lowest Sal from emp table
b) Displays Third highest Sal from emp table d) Displays Second highest Sal from emp table
235. Find the odd statement out

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

a) A table may or may not have a primary key c) A table must have at-least one foreign key
b) A table can have at-most one primary key d) A table might have more than one foreign key

236. In a relational table which of the following is mandatory


a) Foreign Key b) Primary Key c) Candidate Key d) None of the above
237. Identify the correct statement
a) A relationship in 3NF can have partial dependencies in it
b) A relationship in 3NF can have transitive dependencies in it
c) A relationship in 2NF can have transitive dependencies in it
d) A relationship in 2NF can have partial dependencies in it
238. The correct way to get the next value of a sequence into a PL/SQL variable (assuming the sequence is
already created) is
a) iTest := seqTest.NEXTVAL
b) SELECT seqTest.NEXTVAL INTO iTest FROM DUAL
c) both (a) and (b)
d) iTest := seqTest.CURRVAL
239. In the PL/SQL block given below, how many times will the loop be executed?
BEGIN
FOR i in 1..50
LOOP
i:=i+1;
DBMS_OUTPUT.PUT_LINE(' Value of i is ' || i);
END LOOP;
END;
a) 10 times c) Once
b) 25 times d) There is an error in the code

240. Choose the correct answer with respect to the statements given below
I] Functions cannot have out parameter as they already have a return type
II] Functions cannot return more than one value by any means
a) Only I is true b) Both are false c) only II is true d) Both are true
241. What will the following statement do?
PRAGMA EXECEPTION_INIT(EX1,-20000)
a) will associate EX1 with -20000 ** c) can't assign -20000 as it is reserverd error code
b) will raise the exception when encounters - d) none of the above
20000

242. The VALUES clause of the INSERT statement can use functions
a) true b) false
243. The main interfaces that every Driver layer must implement are
a) Driver c) Resultset
b) Connection d) All of the above
244. How to enable output in SQL*PLUS environment

a) server output on b) set server output ON c) set on d) output on

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

VELALAR COLLEGE OF ENGINEERING AND TECHNOLOGY


(Accredited by NAAC with „A‟ Grade & Accredited by NBA)
Thindal, Erode - 638012
(Autonomous)
WIPRO PRP TRAINING
Milestone 3 MCQs
1. In java Script, which of the following event handler method is called when a user clicks on item in the web page?
a) onclick() b) onmouseclick() c) onpress() d) onMousePress()
2. Which of the following is not an attribute of <jsp.set property>?
a. param b.id c.name d.value
3. Which Sof attribute of the <frame> tag is used to indicate that the frame cannot be resolved
a.r esize b.noresize c.name d.src
4. What values is returned when a confirm box is cancelled in javascript?
a.true b.false c.cancel d.none of these
5. Which of the following is a valid variable name in java script?
a.total_no_of_emp. b._emp c.total_ d.all the above
6. Which Statement is true?
a.An XML document cannot have a root element c.All XMl elements must be lower case
b.All Xml elements must have a closing tag d.All XML documents must have a DTD

7. In html which of the following button is used to send form data to a server
a.submit b.button c.reset d.all of the above
8. Syntax for defining action elements in jsp
a.<% %> c.<jsp:action_name attribute="value"/>
b.<% /%> d.none of the above

9. Which method of the servlet will be called when a servelet is undeployed in a server?
a.close b.terminate c.destroy d.abort
10. The values selected in the HTML form elements is passed on to the servlet through
A)HttpServletResponse B)HttpSession C)HttpServletRequest D)cookie
11. the canvas element in html5 is used to
a. to play audio files b. to play video files c.to draw graphics d.none of the above
12. Which of the following session tracking mechanism are supported by servlets
a.uri rewriting d.it supports all the above session tracking
b.cookies mechanism
c.hidden from fields
13. The src attribute of an<IMG> tag indicates
A) a short description of an image C) The height of the image
B) the path of the location of an image D) None of the above

14. If I have to create a checkbox in HTML, which of the following needs to be done?
A) <input type=”check” name=”vehicle” value=”bike”/>
B) <input type=”checkboxgroup” name=”vehicle” value=”bike”/>
C) <input type=”checkbox” name=”vehicle” value=”bike”/>
D) none of the above
15. What is the output of the following code?
<script> Alert(2+3+”3”); </script>
A)233 B) 53 C) error D) None of the above
16. Which of the following is true?
A) XML is a direct subset of SGML C) XML is a kind of dynamic HTML
B) SGML is an application of HTML D) SGML and XML are the same thing
17. Syntax for defining expression in JSP is
A) <%!........ %> C) <%=……. %>
B) %@......... % D) <% ......... %>
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

18. Why do we go for URL rewriting?


a) If client server does not support cookies c) If client machine doesn‟t have enough space
b) If web server does not support cookies d) None of the above

19. Given an HttpServletRequest requested and HttpServletResponse response, which option sets a cookie “username”
with the value “joe” in a Servlet?
A)request.setCookie(“username”,”joe”);
B)request.addCookie(new Cookie(“username”,”joe”));
C)response.addCookie(new Cookie(“username”,”joe”));
D)response.addHeader(new Cookie(“username”,”joe”));
20. Using CSS,how do you make each word in a text start with a capital letter?
A) text-transform:capitalize C) text-transform:uprcase
B) text-transform:uppercase D) You can‟t do with CSS

21. Which attribute of the tag denotes how much space to put between cells?
A) cellspacing C) cellpadding
B) border D) bgcolor
22. What is the output of the following?
<script>
X=”1”;
Y=1;
If(x==y)
Alert(“same”);
Else
Alert(“not same”);
</script>

a) Same b) Notsame c) Error d) None of the above


23. In HTML 5,the input tags, placeholder attribute contents are
A) displayed before the field on webpage
B) displayed inside the field on webpage
C) used to place the field in the given position on webpage
D) no attribute named placeholder is available
24. interface provides declarations for servlet life cycle methods
a. Servlet b. ServletRequest c. HttpServlet d.GenericServlet
25. What is the output ?
<script type=”text/javascript”>
var txt="My name is \"john\"";
document.write(txt);
</script>
A) My name is \”john\” C) error
B) My name is “john” D) None of the above
26. Is javascript a case sensitive language?

A) yes B) no
27. Which of the statement is correct for the given code?
Given MyBean.java
Package test;
Public class MyBean{
Public MyBean(int x) {}
}
And test.jsp
<jsp:usebean id=”my” class=”test.mybean” scope=”page”/>
a) It will work fine 28. Http is a
b) Compiler will complain because there is no
type attribute specified
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

c) Will fail at run time argument constructor


d) It will fail at compile time due to missing no
a) Stateful protocol b) Stateless protocol c) java protocol d) DBMS protocol

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

29. Service method of servlet is called


A. for every client request C. as many times the init method is called
B. once in the life cycle of the servlet D. once per server
30. Which of the following are valid input types in HTML5?

a) email b) number c) button d) all of these


31. Which of the following is the correct way to find or instantiate a JavaBean?
a) <jsp.findbean bean=” name”class=”package.class”/>
b) <jsp.usebean id=” name”class=”package.class”/>
c) <jsp.invokebean id=” name”bean=”package.class”/>
d) <jsp.searchbean bean=” name”path=”package.class”/>
32. ServletConfig is used in the int method of the Servlet to get
a) Servletcontext parameters c) Configuration information from web.xml
b) Configuration information from server.xml d) None of the above
33. Which of the following is a JSP directive?

a) Import b) Session c) isThreadSafe d) Include


34. Which of the following statement is true?
a) The init method is called only when the servlet is first created
b) The init method is called for each user request
c) The init method is designed to be called as many times as required in the life cycle of a servlet
d) It is not possible to specify when the init method will be called
35. Which of the following statements is INCORRECT about servlets?
a) Servlets are executed on server side c) Servlets do not have main() method
b) Servlets are executed on web browser d) Servlets can access RDBMS

36. Which of the following event is trigerred when an element in an HTML Form looses focus?
a) Onclick b) Onblur c)Onfocus d) None of the above
37. To add cookie to the user‟s machine,the following method of the HttpResponse object is used:
a) addCookie() b) addSession() c) setCookie() d) setSession()
38. An XML document is valid if
a) It is well formed c) Conforms to the constraints specified in the DTD
b) It declares a DTD d) All of the above
39. What is the output of the following program?
<script>
alert(Math.round(-10.6));
</script>

a) -11 b) -10 c) Error d) None of the above


40. Which jsp directive lets you do things like importing classes and indicating whether the servlet is multithreaded or
single threaded?
a) Package b) Extends c) Page d) include
41. What method can‟t be used with a window object in javascript?
a.open b.read c.write d.close
42. Which of the given statement is correct regarding the following 2 lines occurring in the same JSPpage?1.<%!int
sum=0;%>..//other valid code.2.<%int sum=0;%>
a.both can‟t occur in the same JSP file c.1 is a directive and 2 is a scriplet
a.1 is a declaration and 2 is an expression d.1 is a declaration and 2 is a scriplet

43. Which of the following is used to insert java values directly into the output of a JSP page?
a.expressions b.scriplets c.directives d.declaration
44. What is the name of deployment descriptor file of a web application?
a.dd.xml b.server.xml c.web.xml d.web-app.xml
45. After compilation a JSP page translates into
a.Applet b.Servlet c.Application d.Midlet
46. The java Server pages (JSP)technology model <%=”India”+username%> is an example of
a.Jsp.Scriplet b.Jsp.Comment c.Jsp.Declaration d.Jsp.Expression

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

47. Which of the following is not a data type in JavaScript?


a.String b.Number c.boolean d.Float

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

48. The attribute used to define a new namespace in XML is


a.NS b.XmlNameSpace c.xmlns d.none of the above
49. What is the return type of an prompt box?
a.s tring c.boolean
b.number d.return type depends upon the type of value entered

50. Which of the following is used to display a password field in a form?


a. <input type=”text” name=”pwd”/> c. <input type=”password” name=”pwd”/>
b. <input type=”passwd” name=”pwd”/> d.none of the above

51. Which of the following is legal JSP SYNTAX to print the value of i?
a.<%int i=1;%><%=i;%> c. <%int i=1%><%=i%>
b. <%int i=1;i;%> d. <%int i=1;%><%=i%>
52. Which of the following statement is NOT true about servlets?
a.servlets start a new process for each request
b.servlets run in the same server process as the HTTP server
c.servlets can use the JDBC API to connect to the database
d.servlets are platform independent
53. HTML tags are case sensitive

a.true b.false
54. Which package does generic servlet belong to?
a.javax.servlet b.javaxservlet.http c.javax.servlet.generic d.java.servlet.http
55. ……..method allows the servlet to receive the value for the given input field passed by the client in the HTML
form
a.getparam(“fieldname”); c. getParameterNames();
b.getParameterValues(); d. getParameter(“fieldname”);
56. HTML5 is
a. HTML+CSS3+JavaScript APIs c. HTML+JavaScript APIs
b. HTML+CSS1+JavaScript APIs d. HTML+CSS2
57. How do you change the left margin of an element?

a.text-indent:20px; b.indent:20px; c.margin:20px; d.margin-left:20px;


58. What will be the output of the following code?
<script language=”javascript”>
X=4+”4”;
Document.write(x);
</script>
ANS:44
59. Which of the following is a valid button type in HTML
a.button b.reset c.submit d.all of the above
60. Which method of the HttpServletRequest object is used to get the value of a form parameter in a servlet?
a.getForm b.formParameter c.getParameter d.getFormValue
61. An array in Javascript is
a.a variable b.an object c.a method d.a function
62. What command skips the rest of a case statement?
a.return b.exit c.continue d.break
63. Name the implicit object of Javax.servlet.http. HttpServletRequest in JSP
a.request b.HttpRequest c.req d.None of the above
64. What is the output of the following?
<script language=”JavaScript”>
Var students=new Array („amar „,„rani „,„vinod‟,‟susil „,„santosh‟)
Var suffixes=new Array(„1st‟,‟2nd‟,‟3rd‟,‟4th‟,‟5th‟)
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

for(var i=3;i>=3;i--){

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

Document.write(„The‟+suffixes[i]+‟student is‟+students[i]);
}
</script>
a. It prints „The 3rd students is vinod‟ c. It prints „The 3rd student is vinod‟
b. It prints „The 4th students is susil‟ d. None of the above

65. What is the correct place in the HTML document from where you can enter to an external style sheet?
a.At the end of the document c.In the head section
b.At the top of the document d.In the body section

66. Which of the following is correct syntax to forward the request to another page?
a. <%2page:forward page=”HelloWorld.jsp”%> c. .<jsp:forward jsp=”HelloWorld.jsp”/>
b. <jsp:forward page=”HelloWorld.jsp”/> d. .<%!forward jsp=”HelloWorld.jsp”/>

67. In Javascript, which of the following event handler method is called when the mouse pointer moves over an item in
the webpage?
a.onMouse() b.onMouseMove() c.onMouseOver() d.onMouseAbove()
68. If a text in HTML needs to be both bold and underlined which of the following format should we choose?
a.<b><i>Hi</i></b> b. <b><u>Hi</u></b> c. .<b>Hi</b> d. .None of the above
69. Your web application named “FWorks”uses special Math.class. This is an unbundled class and is not contained in
any jar file. where will you keep this class file?
a. FWorks/WEB-INF c. FWorks/WEB-INF/lib/classes
b. FWorks/WEB-INF/classes d. FWorks/classes

70. What does following code fragement do?<%int accesscount=0;%>Accesses to page since server
reboot:<%=++accesscount%>
a. prints out the number of times the current page hae been requested since the servlet class was changed
and reloaded
b. prints out the number of times the current page hae been requested by the user
c. always prints one
d.nothing is printed out
71. In HTML target=_blank specifies that
a. the page will shut down c. window will open blank
b. the page is defined as a target and will be d. when clicking a link ,it will open in a new
found by the arrow command window

72. Which protocol would you use to access a file on the World Wide Web through a secure connection?
(HTTPS, HTTP, FTP, SMTP)
73. Which of the following is not true about scriplets?
a) in scriplets statements should be ended with semicolon
b) scriplets code goes into the service method of the JSP‟s compilee servlet
c) scriplets are executed at initialization time
d) scriplets are executed at request time
74. Which of the following is true abput <% @ include %> dirctive and <jsp:include>action?
a) Include directive includs the file at runtime whereas the include action includes the file at translation time
b) Include directive includs the file at translation time whereas the include action includes the file at run
time
c) Both of them includes the file at translation time
d) Both of them includes the file at runtime
75. Which is the correct tag for the smallest heading?
a) <h6> b) <h1> c) <h0> d) <h5>
76. Which of the following allows the web server to store small pieces of data on the client that can be sent back to the
server on subsequent page requests?
(Header,cookie,session,parameter)
77. which method of the HttpServletRequest object is used, if there is a chance of retrieving multiple values for any
given input parameter?
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

(retrieveFormValues,gerFormValues,gerMultipleValues,getParameterValues)
78. which of the following is one of the argument of doGet()method of HttpServlet?

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

10

( Request,Response,ServletRequest,Http ServletRequest)
79. Which is output?
<script language=”javascript” type=”text/javascript”>
Var name1=”Neil”;
Var name2=”Sriram”;
Function greet(who)
{
Document.write(who+”<br>”);
}
</script>
<script language=”javascript” type=”text/javascript”>
greet(name1);
greet(name2);
</script>
a) No output
b) Neil
Sriram
c) Sriram
d) Neil
80. The three life cycle methods of a servlet are called/invoked in this order
a) init(),destroy(),service() c) init(),service(),destroy()
b) destroy(),Init(),service() d) service(),Init(),destroy()

81. The setTimeout(functionname,time) is a method belonging to which of the following object?


a) Form c) Window
b) Document d) It does not belong to any object
82. You can reference an entry in an array using

a) Myarray(0) b) Myarray[0] c) Myarray{0} d) Myarray<0>


83. You need to send large amount of binary data from the browser to a servlet to be processed.what HTTP method
would you use?
a) HEAD b) HIDDEN c) GET d) POST
84. XML is a subset of
a) HTML b) XHTML c) VML d) SGML
85. To define the space between the elements border and content, which of the following CSS property is used?
a) Padding-right:15px; c) Border-style:20px;
b) Border-width:5px; d) Margin:25px;

86. Which method of the servlet will be called to process a clients request in a servlet?
a) Process b) Service c) Execute d) Handle
87. In javascript which of the following event handler method is called when a text field in a web page is changed by
the user?
a.onChange() b.onTextChange() c.onEdit() d.onTextEdit()
88. Which of the following are true regarding naming variables in javascript?
A the variable name can start with an alphabhet
B the variable name can start with an underscore(_)
C the variable name can start with a dollar sign($)
D all of the above are true
89. Between which set of tags does most of the content of your web page need to be placed?
a.<text></text> b. <body></body> c.<head></head> d.<title></title>
90. Which of the following is one of the arguments of doGet() method of HttpServelt?
A.Request b.Response c.ServletRequest d.HttpServletRequest
91. .xml is a specification which is developed by
a.microsoft c.a working group of the world wide web
b.oracle consortium(W3C)
d.none of the above
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

11

92. Which of the following property is used to set the color property of an object called fruit>
A) <jsp.setvalue name=”fruit” property=”color”value=”white/>
B) <jsp.setproperty id=”fruit”name=”color”value=”white”>
C) <jsp.setproperty name=‟fruit”property=”color”value=”white”/>
D) <jsp.setvalue id=”fruit”name=”color”value=”white”>
93. Which of the following is false about servlets?
a.init() gets invoked only once c.init() gets invoked for every request
b.service() gets executed for each request d. service() takes two parameters

94. ----------property specifies the size of the background image .when you use this property, the background image
grows in size ,as you keep appending text
A) background-height C) background-image-width
B) background-origin D) background-size
95. Which of the following is root tag in html?

a. <body> b. <html> c. <head> d. <title>


96. In javascript the variables are declared using keyword
a.dim b. data c. variable d. var
97. Which CSS property is used to change the text color of an element
a) color b) text-color c) fgcolor d) bgcolor
98. To send an html output from the servlet the following method of the HttpResponse object is called
a. getConnectRType(“text/html”) c. setContentType(“text/html”)
b. getParameter(“text/html”) d. setHTML(“html”)

99. A JSP page uses the java.util.ArrayList class many times.Instead of reffering the class by its complete package
name each time.We want to just use ArrayList.Which attribute of page directivemust be specified to achieve this?
a. extends b. import c. include d. package
100. In which deployment descriptor in the <servelrt-mapping> and <servlet>elements defined
a. web.jar.xml b. web-war.xml c web.xml d. ejb.jar.xml
101. Which of the following is the correct URL format,when the browser passes the information to a server called
hellousing GET method?
a. http://www.test.com/hello&key1|value1.key2|value2
b. http://www.test.com/hello?key1=value1&key2=value2
c. http://www.test.com/hello|key1=value1,key2=value2
d. http://www.test.com/hello&key1=value1?key2=value2
102. The alert method belongs to which object?
a. document c. window
b. dot d. it does not belong to any object

103. Which of the following page directive attribute can appear multiple times in a jsp file ?
a) Info b) Session c) Import d) Extends
104. Assuming that lion.jpg cannot be found, what will be displayed when the following code is loaded in the browser?
<img src=‟lion.jpg‟ alt=‟lion‟/>
a) A warning message on the page c) The text „lion‟
b) A warning message in an alert box d) None of the above

105. Given an HttpServletRequest request and HttpServlet Response response.which option sets a cookie “username”
with the value „joe‟ in a servlet?
a) Request.setCookie(“username”) c) Response.addCookie(new name)
b) Request.addCookie(new Cookiename) d) Response.addHead(new)
106. what is the output of the following ?
<script>
X=”1”+2+4;
Alert(x);
</script>

a) 16 b) 124 c) Error d) None of these


107. In a web application where are third party jars are placed?
a) WEB-INF\classes b) WEB-INF\jar c) WEB-INF\lib d) WEB-INF
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

12

108. Syntax for defining Scriplets in JSP is


a) <%........%> b) %@ ......% c) <%!.....%> d) <%=. ... %>
109. In which directory of a web application are the server side .class files kept?

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

13

a) WEB-INF\classes b) WEB-INF\servlet c) WEB-INF\lib d) WEB-INF


110. In order to respond to HTTP requests, a servlet should extend
a) HttpServlet b) GenericServlet c) Servlet d) LogonServlet
111. Which of the following is correct way of importing multiple packages in JSP?
a) <%@pageimport=”java.sql*”,”java.util.*”%>
b) <%@pageimport=”java.sql*”import=”java.util.*”%>
c) <%@pageimport=”java.sql*”;java.util.*”%>
d) <%@pageimport=”java.sql*,java.util.*”%>
112. Whats the output of the following code?
<script language=”java script”>
Function test(){
Var total=10;
Document.write(document.myform.x.value+total);
}
</script>
<form name=”myform”>
<input type =”hidden” value=”35” name=”x />
<input type =”button” value=”click” onclick=”test()” />
</form>
a) 3510 b) 45 c) 10 d) Error
113. In HTML by default the table tag comes with a border
a) True b) False
114. In HTML, which attribute allows the user to give more than one value in a given text box?
a. multiple b.more c.many d.in
115. In order to respond to HTTP requests (requests coming from a web client through a web server to the Servlet
Container) ,a servlet should extend
a.HttpServlet b.GenericSevlet c.Servlet d.LogonServlet
116. <script language =”javascript”>
Function showalert(){
A=5,b=6;
Sum=a+b;
Alert(sum);
}
</script>
Ans:11
117. Which of the following is not a valid html tag?
A) <h1> B) <h4> C) <h6> D) All above are valid
118. The control statement on a do while loop is tested?
Ans: after each time through the loop.
119. Choose the 1 correct answer <%=”Hello Rancher‟s%> This is an example of?
a.jsp declaration b.jsp expression c.jsp directive d.jsp scriptlet
120. In the below Javascript code,
var a=”K”;
var b=12;
a=b;
variable “a” now contains?
a.Number b.Text c.Boolean d.None of the above
121. To See if three variable are equal we would use
a.A=B=C b.(A==B)&&(B==C) c. (A=B)&&(B=C) d. (A==B)&(B==C)
122. Which method of the servlet will be called to process a client‟s request in a servlet?
a.process b.service() c.execute d.handle
123. In a servlet,destroy method is called
a.once per client c.as many times the service method is called
b.only once in the life cycle of the servlet d.once per server

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

14

124. In JavaScript,which of the following event handler methods is called when a submit button is pressed in the web
page?
a.onButtonSubmit() b.onSubmit() c.onButtonPressed() d.onButtonReleased()
125. CSS declarations are pairs seperated by semi colon
a.key value pair b.key property pair c.property value pair d.property key pairs
126. What is the output of the following code?
<script>
x=((45%2)==0?”Hi”:”Bye”);
alert(x);
<script>
a.Hi b.Bye c.Error d.None of the above
127. Which event captured a keypress?
a) onkeydown b)onmousedown c)onfocus d)onclick
128. The property is used to add rounded corners to HTML elements.
a) border-shadow b)border-radius c)box-rounded d)border-image
129. How do you write “Wipro Technologies” in a pop up box?
a) alert(“Wipro Technologies”) c) confirm(“Wipro Technologies”)
b) prompt(“Wipro Technologies”) d)none of the above

130. To place an image in a particular position on the web page which CSS property is used?
a) background-position c) background-align
b) background-placement d) background-alignment
131. Which of the following are valid input types in html file?

a)E-mail b)number c)button d)all of the above


132. Servlet context object is used to access
a) environment information c) user response
b) user request d) browser information
133. Give the valid property to set the text color to blue?

a) font-color:blue b)text-color:blue c)color:blue d)font:blue


134. What is the output of the following?
<script type=”text/java script”>
var x=new Array(1,2,3,4,5);
for(i in x)
{
document.write(x[i]);
}
</script>
a)12345 c) error
b)1.2345 12345 12345E14 d) none of the above
135. Which of the following is the valid scriptlet
a)<% out.println(“hello world”)%> c) <%! out.println(“hello world”);%>
b) <% out.println(“hello world”);%> d) <%! out.println(“hello world”)%>
136. doget() method of the http servlet

a) takes the HttpServletRequest and HttpServletResponse objects as parameters


b) takes only the ServletRequest object as parameter
c) takes no parameters as an arguments
d) takes only the ServletRequest and ServletResponse object as parameter
137. In CSS a selector contains declarations
a) zero or more b)only one c)one or more d)no or zero declaration
138. What is the html feature that divides a webpage into two or more scrollable parts
a) split page b)frame c)form d)table
139. Identity the selector (CSS syntax part) from the given CSS statement.
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

15

H1{color:red:}

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

16

A.H1 B.color C.red D.{}


140. The min, max and step attribute can be used with which of the following input types of HTML5?
A.email B. number C.search D.url
141. Which of the following is a valid JSP declaration?
A.<%=”Hello”%> B.<%$ int x=10 %> c.<%! int x=10;%> D.<% int x=10;%>
142. What does isNAN function do in javascript?
A. Return true if the argument is not a number C. Return true if the argument is a number
B. Return false if thev argument is not a number D. none of the above
143. What will be the output of the following piece of code?
<title>Very Simple</title>
<% int salary; %>
Current Salary is:<%=salary%>
A.Current Salary is:null C.Current Salary is:0
B. This code will not complile D.none of these

144. When both internal and external style sheet are defined which of the following is true?
A.external style sheet over rules all the other styles given
B. internal style sheet over rules the external styles defined
C. defining both internal and external style sheets for one page is not possible
D. user has to explicitly declare which style to apply
145. Using servlets, the getParameterValues() method returns a
A.String array B.int value C.String D.void
146. The state information for a client is stored in
a) The HttpServletSession object c) The ServletSession object
b) The SessionScope object d) The HttpSession object
147. Which of the following are true about HTML attributes?
a)Attributes provide additional information about an element
b)Attributes are always specified in the start tag
c) Attributes come in name/value pairs like name=”value”
d) all the above

148. In javascript, which of the following event handler method is called when an item on the web page gains focus?
a)OnLoad() b)OnFocusGained() c)OnFocus() d)OnGained()
149. What is the correct javascript syntax to write “Hello World”?
a) response.write(“Hello World”) c) document.write(“Hello World”)
b)<%=”helloworld”%> d)None of the above

150. Which of the button type in HTML is used to reset the values of all the controls of a form to their initial values?
a.submit b.button c.reset d.none of these
151. Which attribute of <form> tag is used to specify where to send the form-data when a form is submitted
a.method b.name c.action d.none of these
152. Order of priority for applying the rules
1.browser default 2.external 3.internal 4.inline
a)1 2 3 4 b)2 3 4 1 c)1 4 3 2 d)4 3 2 1
153. What is XHTML stands for
a) eXtra Hypertext Markup Language c) eXtended Hypertext Markup Language
b)eXtension Hypertext Markup Language d) eXtensible Hypertext Markup Language
154. External style sheet should be stored with extension

a) XCS b)CSS c)CSX d)CS


155. A head request is just like a get request except that
a) it asks server to return response headers only and not the complete resource.
b) is used to check characteristics of a resource without downloading it
c) is used when you don't need actual file contents
d) all of the above
156. The web browser and the web sever talk to each other using
a) File Transfer protocol 157. java.io.Serializable is
b) HyperText Transfer protocol
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

17

c) HTML
d) None of the above

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

11

a) Marker interface in Java c) a class containing the serialize function


b) contains functionality required for d) all of the above
serialization of objects
158. Who maintains the life cycle of the servlet?

a) Servlet container b) the client c) Both a and b d) none of the above


159. Which of the following method is called when the Servlet is first loaded?
a) initialize() method b)both of the above c) init() method d)none of the above
160. Which of the following is a feature of Servlet?
a) Supports Multithreading c) Protocol independent
b) Platform independent d) All of the above
161. Any Java class can be a servlet provided
[i] It implements the javax.servlet.Servlet Interface.
[ii] Extends from any class that implements the same.
a) Only i is true, ii cannot be used c) Either of i or ii can be used
b) Only ii is true, i cannot be used d) Both i and ii cannot be used
162. Servlets can run using
a) Any web server

b) Any web server with built in Servlet engine / add on for the servlet engine
c) Any server that has JVM inside it.
d) all of the above
163. Pre-requisites for running Servlets are
a) Web Server that is Java Enabled C) Java Runtime Environment
b) Servlet API Class library d) All the above
164. HTTP header fields include
a) Content-length c) Type of request - POST or GET
b) Cookies d) All the above

165. Method that is used to retrieve value from a session variable is (assuming session is an object of HttpSession)
a) session.getValue("sessionvarname"); c) session.getDetails("sessionvarname");
b) session.getAttribute("sessionvarname"); d) Options a and b

166. If the user opens two instances of browsers separately and accesses the same ASP page, how many session objects
will be created on the Application Server?
a)1 b)2 c)3 d)4
167. GET method of HTTP is more secure than POST method
a) true b) false c) can't say d) none of the above
168. 'this' is used for referring
a) current object c) super class object
b) any object used in the application d) none of the above

169. Name the class that includes the getSession method that is used to get the HttpSession object.
a) HttpServletResponse c) SessionContext
b) HttpServletRequest d) SessionConfig

170. The method getWriter returns an object of type PrintWriter. This class has println methods to generate output.
Which of these classes define the getWriter method? Choose the correct option
a) HttpServletRequest c) ServletConfig
b) HttpServletResponse d) ServletContext

171. To send text output in a response, the following method of HttpServletResponse may be used to get the
appropriate Writer/Stream object. Choose the correct option.
Downloaded by Sanket !! ([email protected])
lOMoARcPSD|43369215

a) getStream b) getOutputStream c) getBinaryStream d) getWriter 12


172. Which method returns names of the request parameters as Enumeration of String objects
a) getParameter b) getParameterNames c) getParameterValues d) None of the above

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

13

173. Servlets classes specific to your application are placed in which directory on the TOMCAT Server?
a) /lib/ b) /WEB-INF/classes/ c) /classes d) /WEB-INF/lib/
174. If a frame uses a grid layout manager and does not contain any panels,
a) then all the components within the frame are of different width and height
b) then all the components within the frame are the same width and height.
c) then all the components within the frame are smaller
d) then all the components within the frame are not completely visible
175. Servlet becomes thread safe by implementing the javax.servlet.SingleThreadModel interface
a) as every request is handled by separate instances of the servlet
b) as a single thread serves all the client requests
c) as all the requests are serialised
d) a first to-be loaded servlet and is loaded by the server during startup
176. You must ideally use Servlets for
i] Extending Server functionality and simple business logic
ii] Work flow management and presentation logic
iii] Work flow management and complex database queries
iv] NON-HTML data generation such as XML generation and parser
a) i only b) i, ii, iii c) i and ii only d) All of i, ii, iii and iv
177. Some purposes for which servlets can be used are:
i] file access on the client side iii] any purpose at the server end
ii] starting distributed transactions iv] calling an enterprise bean
a) All of i, ii, iii and iv c) iii only

b) ii, iii and iv only. File access is not possible. d) None of i, ii, iii and iv
178. Looking at the following piece of the code, Select the correct statement out of the given options
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
a) This is exactly same as import statement
b) This is used to make a connection with database
c) Usually written in the init() method of Servlet to load the driver into memory**
d) None of the above
179. Servlets can follow
a) single thread model b) multi thread model c) both d) none of the above
180. Which of the following server can host servlets?
a)Apache server b)IIs c)Windows 2000 Server d)Tomcat Server
181. Select the odd man out of
a) JButton b) Dialog c) ScrollPane d) Panel
182. Which of the following is the best answer
a) Although webservers can be configured to ports other than 80 for http requests, it is fine to configure
them to 8000 in production environments
b) Although webservers can be configured to ports other than 80 for http requests, it is not fine to configure them
to 8000 in production environments
c) Webservers do not allow you to configure to ports other than 80 and 443
d)Ignore this Option
183. The following method is used to create a PrintWriter object that can be used to write text to the response
a) getWriter() b) getOutputStream() c) getBinaryStream() d) getStream()
184. The service() method has objects of these classes as parameters - HttpServletRequest and HttpServletResponse
a) True b) False c) Ignore this option d) Ignore this option
185. Consider the following servlet
import javax.servlet.*;
import javax.servlet.http.*;

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

14

import java.io.*;
public class MyServlet extends HttpServlet {
int var;
public void init() throws ServletException {
var=0;
}
....}
For every browser request, a new instance of the servlet is created by the server
a) True b) False c) Ignore this option d) Ignore this option
186. Name the class that can be used to get the cookies from the client browser
a. HttpServletResponse b) HttpServletRequest c) SessionContext d) SessionConfig
187. Which of the following is not a server-side technology?
a) Servlets b) Java Server Pages c) DHTML d) CGI
188. Which method returns an array of String objects containing all of the values the given request parameter has
a) getParameter() b) getParameterNames() c) getParameterValues() d) None of the above
189. ASP Scripting
a) is browser dependent scripting c) is built on COM based technologies
b) Can be copied and downloaded by the client d) Can be coded only in VB Script
browser
190. Choose the correct statement

a) To support ASP on a windows machine, ASP.dll must be present.


b) One can set client side cookies by using the request.Cookies indexed property
c) Data from multiple HTML forms can be selected by Request.Forms method
d) All of the above
191. Choose the incorrect statement
a) Cookies expire only when deleted by the client user.
b) Cookies cannot be made to expire programmatically.
c) AUTH_TYPE server variable is used to find out the type of author of the web page.
d) All of the above
192. Choose the incorrect statement
a) Redirect method belongs to the Response object
b) ScriptTimeOut property belongs to the Request Object
c) Abandon method belongs to the Session object
d) CreateObject method belongs to the Server object
193. Which method is used to transfer the request from the client to another location?
a) Flush b) Redirect c) End d) Clear
194. Can cookies be retrieved from the Request Object?
a) True b) false c) Ignore d) Ignore
195. As far as Server side functionality is concerned, the GET method is more secure that the POST method in the
sense that form actions are not repeated for repeated invocations.
a) TRUE b) FALSE c) Ignore this option d) Ignore this option
196. Cookies can be written to in:
a) Response Object b) Request Object c) Both the above d) Ignore this option
197. Cookies stored by one web server are hidden from the other web servers
a) TRUE b) FALSE
198. How can a servlet can call a HTML document & pass data to it? Passing data is important.
a) request.sendRedirect("something.html?required_parameters")
b) No way a servlet can make a call to an HTML document
c) Servlet can write HTML to response object, but cannot pass parameters

Downloaded by Sanket !! ([email protected])


lOMoARcPSD|43369215

15

d) Ignore this option


199. A head request is just like a get request except that
a) it asks server to return response headers only and not the complete resource.
b) is used to check characteristics of a resource without downloading it
c) is used when you don't need actual file contents
d) all of the above
200. What will happen when the code is compiled and executed?
import javax. servlet.*;
import javax.servlet.http.*;
import java.io.*;
class TestServlet extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
response.setContentType("text/html");
PrintWriter out=response.getWriter();
out.println(" Servlet Exam");
out.close();
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
doGet(request, response);
}}
a) Compilation Error
b) Compiles fine but will not be executed. Displays error.
c) Displays output as Servlet Exam in HTML bold text
d) Displays output as Servlet Exam
201. In java, three tier architecture is usually( in most generic way) implemented using
a) Front end in HTML, middle tier in pure java, odbc in backend
b) Front end in applets, middle tier in beans, odbc in backend
c) Front end on HTML/Swing, middle tier in Servlets/Beans/EJB and Database
server in the back end.
d) none of the above
202. Why are programs needed on Server-side?
a) Dynamic Content generation c) Transactions
b) Database access d) All of the above

203. The URL in the POST method can be used to find out the query parameters
a) true b) false
204. Which of the following is not a mandatory attribute for <APPLET> tag?
a) code b) width c) height d) name
205. components can be used for guiding the user with description for input components in GUI.
a) JLabel b) JPanel c) JButton d) Any of the above
206. Panel is a container
a) from which you inherit the Applet class
b) that helps you add multimedia elements
c) that helps you add event handling for your applications
d) that helps you to create windows for your applications
207. init method of a servlet is called only once in its lifetime
a) False b) True c) Invalid option d) Invalid option

Downloaded by Sanket !! ([email protected])

You might also like