JAVA 1 Soln
JAVA 1 Soln
JAVA
Contents
AWT .............................................................................................................................................................................. 2
CLONE REFLECTION API................................................................................................................................................ 5
COLLECTION API ........................................................................................................................................................... 6
DESIGN PATTERN ......................................................................................................................................................... 9
EXCEPTION ................................................................................................................................................................. 10
FILE HANDLING........................................................................................................................................................... 19
FUNDAMENTAL .......................................................................................................................................................... 24
GENERICE ................................................................................................................................................................... 29
HIBERNATE ................................................................................................................................................................. 30
INHERITANCE ............................................................................................................................................................. 35
JAVA FX....................................................................................................................................................................... 48
JDBC............................................................................................................................................................................ 48
JSF............................................................................................................................................................................... 52
JSP .............................................................................................................................................................................. 52
MULTITHREADING...................................................................................................................................................... 60
MVC ............................................................................................................................................................................ 68
Oops ........................................................................................................................................................................... 68
SERVLET ...................................................................................................................................................................... 80
SOCKET PROGRAMMING ........................................................................................................................................... 89
STRUTS ....................................................................................................................................................................... 92
SPRING ....................................................................................................................................................................... 95
SWING ........................................................................................................................................................................ 97
1
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
AWT
1. Adapter class is not available for
a: ItemListener b: MouseLIstener c: KeyListener d: WindowListener
2. Given
public class MyApp extends Applet
{
public MyApp(int k)
{
}
}
What will happen to the above code?
a: compilation error “cannot instantiate MyApp” b: runtime error “paint() method not available”
c: runtime error “InstantiationException” d: compilation error “paint() not defined”
3. Given
public class MyApp2 extends Applet
{
@Override
public void init()
{
setLayout(new GridBagLayout());
GridBagConstraints gbc=new GridBagConstraints();
gbc.gridwidth=3;
gbc.gridheight=2;
add(new Button("ok"));
}
}
What will happen?
a: compiler error “add method must take 2nd argument as GridBagConstraints”
b: exception during runtime
c: Button will appear according to gridwidth and gridheight specified
d: Button will appear but not according to gridwidth and gridheight specified.
5. Given
2
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
setLayout(new BorderLayout());
add("south",new TextField(20));
What will happen to the above code?
a: compiler error c: textfield will be displayed properly at south
b: exception d: textfield will be displayed in the center,since u have given illegal argument.
7. Given
public class Trial extends Frame
{
public Trial(String mess)
{
MenuBar mb=new MenuBar();
// here
}
}
How will u add “mb” to the frame?
a: addMenuBar(mb); b: setMenuBar(mb); c: mb.addMenuBar(); d: add(mb);
10. java.awt.Component class method getLocation() returns Point (containg x and y cordinate).What
does this x and y specify
a: Specify the position of components lower-left component in the coordinate space of the component's
parent.
b: Specify the position of components upper-left component in the coordinate space of the
component's parent.
c: Specify the position of components upper-left component in the coordinate space of the screen.
d: None of the above
11. When u invoke “repaint()”, for a lightweight component , the AWT package calls which component
method?
a) repaint() b) update() c) paint() d) draw()
3
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
13. Which of the following the valid way to embed an applet class named myapplet into a web page.
a) <applet class=myapplet.class width=100 height=100> </applet>
b) <applet code=myapplet width=100 height=100> </applet>
c) <applet code=myapplet.class height=100 width=100 > </applet>
d) <applet param=myapplet.class width=100 height=100> </applet>
19. Given
setLayout(new BorderLayout());
add(new TextField(20));
What will happen to the above code ?
a) compiler error
b) exception
c) textfield will not be displayed since u haven’t mentioned an area.
4
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
d) textfield will be displayed in the center.
20. Given
import java.awt.*;
public class MyFr2
{
Button b1,b2;
public MyFr2(String title)
{
Frame f=new Frame(title);
f.setLayout(new BorderLayout());
b1=new Button("ok");
b2=new Button("cancel");
f.setLayout(new FlowLayout());
f.add(b1);
f.add(b2);
f.setSize(400,400);
f.setVisible(true);
}
public static void main(String args[])
{
new MyFr2("My Window");
}
}
What will happen to the above code ?
a) compiler error “can not set layout twice”
b) frame will be displayed with only one “cancel” button
c) frame will be displayed with two buttons.
d) exception during runtime.
22. What is sent to the user via HTTP, invoked using the HTTP protocol on the user’s computer and run
on the user’s computer as an application?
a) A Java application c) A Java applet
b) A Java Servlet d) None of the above
CLONE REFLECTION API
1) Cloneable interface contains “clone()” method
A. True B. False
5
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
2) Clone method is declared as throws
A. IOException
B. CloneNotFoundException
C. CloneNotSupportedException
D. None of the above
8) Static nested class methods can access outer class members directly
A. True B. False
COLLECTION API
1. One of the following throws ConcurrentModificationException if we try to modify while iterating over
it.
A: Hashtable
B: CopyOnWriteArrayList
6
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
C: ArrayList
D: ConcurrentHashMap
2. The default capacity and load factor for Map implementations are
A: 12 and 0.60
B: 16 and 0.75
C: 20 and 0.75
D: 18 and 0.60
3. Given
Class Animal{void eat(){}}
Class Dog extends Animal{}
Class Cat extends Animal{}
Void disp(List<? super Dog> mylist)
Which of the following is the wrong argument to disp ?
A: ArrayList of Animal
B: ArrayList of Dog
C: ArrayList of Object
D: All the above are correct arguments.
5. Which collection class allows you to grow or shrink its size and provides indexed access to its
elements, but whose methods are not synchronized?
A: java.utiI.HashSet
B: java.utiI.LinkedHashSet
C: java.utiI.List
D: java.util.ArrayList
6. Which of the following class uses String as key to store the value in object?
a) Dictionary b) Array c) ArrayList d) Properties
8. ________ can be used to control the order of certain data structure and collection of object too.
7
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
a) Serial comparators b) natural comparators c) comparators d) all of the above
10. What is the sequence followed by HashMap or HashSet while adding or retrieving entries.
A: ==, equals(), hashcode()
B: equals(), == , hashcode()
C: hashcode() , == , equals()
D: none of these
11. If you try to invoke “remove()” method on iterator of CopyOnWriteArrayList , it raises following
exception
A: ConcurrentModificationException
B: UnsupportedOperationException
C: IllegalOperationException
D: none of these
18. When you add any object inside Collection API implementation class, its copy is added.
A. True B. False
20. In map implementation when hashcode of two keys are same it is called as?
A. Hashing
B. Hash Collision
C. Hash Clash
D. None of these
21. One of the following allows us to define more than one strategies.
A. Comparator
B. None of these
C. Enumeration
D. Comparable
DESIGN PATTERN
1. Which design pattern would you use to have a prototypical instance determine the concrete class of
object being created?
A: Prototype factory design pattern
B: Virtual prototype design pattern
C: Abstract prototype design pattern
9
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
D: Prototype design pattern
5. Which of the following is NOT an advantage of using the Session Facade pattern?
A: Hides model complexity from the client
B: Reduces network traffic
C: Provides a simple interface to the client
D: Enables the client to control transactions
6. You are building the server side of an application and you are finalizing the interfaces that you will
provide to the presentation layer. However, you have not yet finalized the access details of the business
services. Which design pattern should you use to mitigate this concern?
A: Model-View-Controller
B: Data Access Object
C: Business Delegate
D: Facade
EXCEPTION
11
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
5. Imagine there are two exception classes Exception1 and Exception2 derived from the Exception class.
Given these two definitions:
class First
{
void test()throws Exception1,Exception1
{
}
}
class Second extends First
{
void test()
{
}
}
Now define a class “Third” derived from “Second” and override “test ()” method inside it.
What exceptions can Third’s test() method throw?
a) Exception1 b) Exception2
c) No checked exceptions d) it can declare any checked
6. What letters get written to the standard output with the following code?
public class MyClass
{
public static void main(String args[])
{
try
{
method();
}
catch(Exception ie)
{
}
}
static void method()
{
try
{
wrench();
System.out.println("a");
}
catch(ArithmeticException ae)
{
System.out.println("b");
}
finally
{
12
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
System.out.println("c");
}
System.out.println("d");
}
static void wrench()
{
throw new NullPointerException();
}
}
a) A b) b c) c d) compilation error
10 Given:
1. public class Foo {
2. public static void main(String[] args) {
3. try {
4. return;
5. } finally {
6. System.out.println( "Finally" );
7. }
8. }
9. }
What is the result?
a. Finally b. Blank c. Null d. None of the above
11. In exception handling mechanism, finally block is always executed, even if no exception occurred in
the try block
a. True b. False
}
}
a) compile error b) neither compilation nor runtime error
c) no compilation error but exception at runtime.
15. Which statement is true,if the following program is run by java test10 ?
public class test10
{
public static void main(String []args)
{
String []num={"one","two","three","four"};
15
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
if(args.length==0)
{
System.out.println("Zero");
}
else
{
System.out.println(num[args.length]+" arguments”);
}
}
}
A. The program won’t run because argument of main is not properly mentioned
B. The program will throw a NullPointerException
C. The program will display Zero when executed
D. The program will display 0 arguments when executed
17. Assuming a method contains code which may raise an Exception (but not a RuntimeException), what
is the correct way for a method to indicate that it expects the caller to handle that exception:
A. throw Exception
B. throws Exception
C. new Exception
D. Don't need to specify anything
18. What is the result of executing the following code, using the parameters 4 and 0:
public void divide(int a, int b)
{
try
{
int c = a / b;
}
catch (Exception e)
{
System.out.print("Exception ");
}
finally
16
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
{
System.out.println("Finally");
}
A. Prints out: Exception Finally
B. Prints out: Finally
C. Prints out: Exception
D. No output
19. Given
public class MyClass
{
public static void main(String args[])
{
String s1="hello";
String s2=new String("hello");
String s3="hello";
System.out.println(s1==s2);
System.out.println(s1==s3);
System.out.println(s1.equals(s2));
}
}
What will be the output ?
21. Can you declare method local variable as final and can an abstract class may be final?
A. Yes, yes
B. Yes, no
C. No, yes
D. No, no
22. Which of these methods of String class is used to obtain character at specified index?
A. char()
B. charOn()
C. charat()
D. charAt()
System.out.println("int = "+i);
System.out.println("float = "+f);
System.out.println("double = "+d);
System.out.println("boolean = "+bl);
}
}
A. Int=0
float=0.0
double=0.0
boolean=false
32. If u want to create checked exception as user defined exception u need to extend
A. RuntimeException
B. Throwable
C. Exception
D. Error
33. When u write one try and multiple catch the most specific catch should precede the most
generic catch
A. True
B. False
FILE HANDLING
1. One of the following class provides “seek ()” method
A: FileInputStream
B: File
C: RandomAccessFile
D: FileReader
2. Given
File f=new File("abc.txt");
FileInputStream fis=new FileInputStream(f);
19
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
byte arr[]=new byte[100];
which statement will read content of “abc.txt” into arr.
A: arr=fis.read()
B: f.read(arr)
C: arr=f.read()
D: fis.read(arr)
5. Classes that do not implement ______interface will not have any of their State serialize or
deserialized.
A: List
B: SingIeThreadModeI
C: Serializable
D: Comparable
output- 5 5
how does readObject() of ObjectInputStream indicate end of file?
a. returns null
b. "" -1
c. throws java.io.EOFException - correct ans
d. closes automatically
c) for(int i=0;i<=9;i++)
{
fos.writeInt(i);
}
d) DataOutputStream dos=new DataOutputStream(fos);
for(int i=0;i<=9;i++)
{
dos.writeInt(i);
}
10. What is the permanent effect on the file system of writing data to a new FileWriter("report"), given
the file report already exists?
1. The data is appended to the file
2. The file is replaced with a new file
3. An exception is raised as the file already exists
4. The data is written to random locations within the file
13. Given
class base
{
int k;
}
class sub implements Serializable
{
base b=new base();
int j;
22
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
}
If we try to serialize instance of sub class,
A: sub as well as base state will be serialized
B: NotSerializableException
C: only sub instance will be serialized
D: compiler error “ cannot serialized object having non-serializable parent”
14. Which class is not serialized
A: java.lang.Thread
B: java.lang.Applet
C: java.lang.Class
D: All of the above
21. In case of Serializable when u deserialize an object constructor does not get invoked.
A. True B. false
23
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
C. NullPointerException
D. none of the above
25. in case of Externalizable when u deserialize an object first readExternal() is called and then constructor is
called.
A. True B. false
27. If inner class implements Externalizable we don’t get any problem while deserialization
A. True B. false
28. If static nested class implements Externalizable we don’t get any problem while deserialization
A. True B. false
FUNDAMENTAL
1. Given the following code
public class test10
{
public static void main(String args[])
{
int x,y;
y=10;
}
24
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
}
On Compilation of above code
A: Local variable y might not have been initialized
B: no error
C: Local variable x might not have been initialized
D: Local variable x initialized but not declared.
3. Given the following class,which statements if inserted at position 1 will cause a compilation error?
public class test1
{
int a;
int b=0;
static int c;
public void disp()
{
int d;
int e=0;
// Position 1
}
}
A: a++
B: b++
C: c++
D: d++
25
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
4. Scanner class is the part of
A: java.io
B: java.scanner
C: java.util
D: java.lang
System.out.println("int = "+i);
System.out.println("float = "+f);
System.out.println("double = "+d);
System.out.println("boolean = "+bl);
}
}
a) Int=0
float=0.0
double=0.0
boolean=false
b) Int=0
float=0.000
double=0.000
boolean=false
26
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
B: 432
C: 43
D: 543
7.Given:
1) class 00P{
2) public static void main(String[] args) {
3) doStuff(1);
4) doStuff(1 , 2);
5) }
6) // insert code here
7) }
Which of the following inserted independently at line 6, will compile?
A: static void doStuff(int... doArgs) { }
B: static void doStuff(int[] doArgs) { }
C: static void doStuff(int... doArgs, int y) { }
D: static void doStuff(int doArgs...) { }
8. What is coercion?
A: Coercion is a phenomenon of promoting sub class to super class
B: Coercion is a phenomenon of casting super class to sub class
C: Coercion is an changing the data types according to cast operator
D: Coercion is the conversion between different data types done while compiling
12. After execution of the following code fragment, what are the values of the variable x, a and b?
int x, a = 6, b = 7;
x = a++ + b++;
1. x=15,a=7,b=8
2. x=15,a=6,b=7
3. x=13,a=7,b=8
4. x=13,a=6,b=7
14. Which declarations of main() method are valid in order to start the execution of an application?
a) public void main(String args[])
b) public void static main(String args[])
c) public static main(String args[])
d) public static void main(String args[])
16. You want to find out the value of the last element of an array. You write the following code. What
will happen when you attempt to compile or run it?
28
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
Public class MyAr
{
Public static void main (String argv[])
{
int [] I = new int [5] ;
System.out.println(I [5]);
}
}
1. An error at compile time.
2. An error at run time.
3. The value 0 will be output.
4. The string “null” will be the output
6) If the base class reference referring to sub class array then there is a possibility of
A. IllegalArrayException
B. ArrayStoreException
C. NullPointerException
D. none of the above
29
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
8) In case of <? super ……> we can add
A. True B.false
9) List<? Super Thread> mylist=new ArrayList<Object>() will work
A. Yes B. no
10) List <? Super Dog> mylist=new ArrayList<Animal>() mylist.add(new Cat()); will work
A. Yes B. no
11) List<?> allows u to add
A. True B. false
12) List<Object> allows u to add
A. True B. false
HIBERNATE
1. Hibernate entity can be
A: transient
B: detached
C: persistent
D: all of the above
2. When transaction completes, all the associated persistent objects still exists in memory but they lose
their association with the session on encountering one of the following method
A: session.flush()
B: trasaction.close()
C: session.close()
D: none of the above
3. In hibernate,If the developer is not certain about the existence of the object.
A: load() method should be used
B: get() method should be used
C: retrieve() method should be used
D: all the above are same with not much difference.
8. A join which combines result of both left and right outer join is
A: Left Right Join
B: Right Outer Join
C: Full Join
D: Left Join
12. What is the root tag element in the hibernate configuration file?
A: <hibernate-cfg>
B: <hibernate-conf>
C: <hibemate-configuration>
D: <hibemate>
31
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
13. Once the hibernate session is closed, in which state the object remains?
A: detached
B: transient
C: pesistent
D: garbage collector
33
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
34. There are core interfaces that are used in just about every hibernate application. Using these
interfaces, you can store and retrieve persistent object and control transactions. Select all the interfaces
that you see.
a. Configuration interface
b. Query and Criteria interfaces
c. All of the above
d. None of the above
36. If the validation fails what will be returned by the validate () method?
34
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
a) Success b) input c) login d) error
INHERITANCE
1. What is the output of following code.
class a
{
static
{
System.out.println(" static a");
}
}
class b extends a
{
static
{
System.out.println(" static b");
}
}
class c extends b
{
static
{
System.out.println(" static c");
}
}
public class myclass
{
static
{
System.out.println(" static
myclass");
}
public static void main(String args[])
{
new c();
System.out.println("in main");
}
}
36
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
i+=v*2;
}
}
public class test6
{
static void disp(base b)
{
b.add(8);
b.print();
}
public static void main(String args[])
{
disp(new sub());
}
}
A: 9
B: 18
C: 22
D: 21
37
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
D: Trial, Object
}
}
a. base b. sub3 c. sub1 d. sub2
9. Given the following code,what can be said about the statement s=(sub)b ?
class base
{
}
class sub extends base
{
}
public class test12
{
public static void main(String args[])
{
base b=new base();
sub s=new sub();
s=(sub)b;
}
}
a. legal at compile time but illegal at runtime
b. illegal at compile time
c. legal at compile and runtime ,but (sub) cast is not needed
d. legal at compile and runtime ,but (sub) cast is strictly needed.
10. What will happen when you attempt to compile or run this code?
class Base
{
public final void amethod ()
{
system.out.println (“amethod”);
}
}
public class Fin extends Base
{
public static void main (String argv [] )
{
40
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
Base b = new Base() ;
b.amethod () ;
}
}
a. Compile time error indicating that a class with any final methods must be declared final
itself
b. Compile time error indicating that you inherit from a class with final methods.
c. Run time error indicating that Base is not defined as final.
d. Success in compilation and output of “amethod” at run time
11. class Foo
{
int num;
Bar comp=new Bar();
}
class Bar
{
boolean flag;
}
class Baz extends Foo
{
Bar thing=new Bar();
double d;
}
a. A Bar is a Baz
b. A Foo has a Bar
c. A Baz is a Foo
d. A Foo is a Baz
e. A Baz has a Bar.
13. Given
interface emp // functional interface
{
String wish(String name);
}
Lambda expression in order to use above interface would be:
a. emp ref2=(String name)->{ return "Welcome to our site\t"+name;};
b. emp ref2=(String name){ return "Welcome to our site\t"+name;};
c. Both A and B
d. None of the above
14. How restrictive is the default accessibility compared to public, protected and private accessibility?
16. The programmer must explicitly create the System.in and System.out objects.
A. True B. False
17. A method within a class is only accessible by classes that are defined within the same package as the
class of the method. How can such a restriction be enforced?
42
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
A. Declare the method with the keyword “public”
B. Declare the method with the keyword “protected”
C. Do not declare the method with any modifiers.
D. Declare the method with the keyword “private”
E. Declare the method with the keyword “package”
18. A final class cannot have any abstract methods.
A. True B. False
}
1. Test t=new Test();
2. System.out.println(t.str);
3. t.str=null;
4. t=null;
5. System.out.println("done");
At which line the object created at 1 will be marked for garbage collection?
A: Line 3
B: Line 4
C: Can’t say exactly when
44
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
D: both Line3 and Line4
if(str1.equals(str3))
{
System.out.println("str1 and str3 are equals");
}
else
{
46
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
System.out.println("str1 and str3 are not equals");
}
A: str1 and str3 are ==, str1 and str3 are equals
B: str1 and str3 are not ==, str1 and str3 are equals
C: str1 and str3 are ==, str1 and str3 are not equals
D: compilation error
28. Java supports
A. single level inheritance
B. multi-level inheritance
C. hierarchical inheritance
D. all of the above
29. Super must be on first line if we want to invoke base class constructor.
A. True
B. False
30. Super need not be on first line if we want to invoke base class method.
A. True
B. False
31. <default> is more accessible than protected.
A. True
B. False
32. Final keyword can be applied to
A. Instance member
B. Class variable
C. Local variable
D. All of the above
33. In java we can apply static modifier for local variable.
A. True B. False
34. In order to make a class abstract:
A. Apply abstract keyword to class
B. Declare abstract method inside class
C. Both a and b
D. None of the above
35. In order to check “is-a” relationship, we use following operator
A. Is-a
B. Instanceof
C. Is_relationship
D. None of the above
47
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
B. It gives runtime error
C. Compiler automatically removes the argument
D. It becomes overloading.
JAVA FX
1. In JavaFX following class is acting as a container for all the contents
a. Scene b. Stage c. LayoutPane d.None of the above
2. In order to start every JavaFX application you must invoke following method
a. Init() b. Start() c. Launch() d. None of the above
JDBC
1. Which of the following code will you use to get a count of the columns in the result?
A. ResultMetaData rsmd=DatabaseMetaData.getMetaData();
int columns=rsmd.getColumnCount();
B. ResultSetMetaData rsmd=new ResultSetMetaData(result);
int columns=rsmd.getColumnCount();
C. ResultSetMetaData rsmd=result.getMetaData();
int columns=rsmd.getColumnCount();
D. DatabaseMetaData md=result.getMetaData();
int columns=md.getColumnCount();
48
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
d. #
11. If we use update statement inside “execute()” method of Statement, it will return
A: false
B: true
C: 1
D: 0
49
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
12. When driver is not found, it results in
A: DriverNotFoundException
B: CIassNotfoundException
C: SQLException
D: None of the above.
13. Connection is
A: interface
B: class
C: package
D: None of the above.
14. Name the most suitable execution method in JDBC , for firing DML queries.
a. executeQuery()
b. executeUpdate()
c. executeQueue()
d. executeDynamicQuery()
17. Which driver is efficient and always preferable for jdbc applications?
a) Type – 4 b) Type –1 c) Type –3 d) Type –2
18. The parameters of PreparedStatement object are _______ when the user clicks on the query button.
a) Initialized b) started c) paused d) stopped
50
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
D. Native-API Driver
27. Every driver class has ________ which registers itself with the DriverManager
a) Static method
b) static block
c) constructor
d) none of the above
51
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
JSF
1. Front Controller in JSF is
a) DispatcherServlet
b) ActionServlet
c) FacesServlet
d) none of the above
JSP
1. Which of the attribute of JSP mentioned below is not available in servlet?
A: request
B: session
C: page
D: context
52
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
C: JspDestroy
D: jspService
8. Which JSP expression tag will print the context initialization parameter named “uname”?
A: <%= application.getAttribute(“uname”)%>
B: <%= application.getInitParameter(“uname”)%>
C: <%= request.getParameter(“uname”)%>
D: <%=contextParam.get(“uname”)%>
10. The implicit JSP objects like request, response, and out are only visible in the _jspService() method.
a. True b. False
53
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
11. To fill up all bean properties with HTML form elements which of the following statements can be
used,
a. <jsp:synchronize name="BeanName" />
b. <jsp:setProperty name="BeanName" property="" />
c. <jsp:setProperty name="BeanName" property="*" />
d. <jsp:setProperty name="BeanName" property="All" />
12. Why use RequestDispatcher to forward a request to another resource, instead of using a
sendRedirect?
a. Redirects are no longer supported in the current servlet API.
b. Redirects are not a cross-platform portable mechanism
c. The RequestDispatcher does not use the reflection API.
d. The RequestDispatcher does not require a round trip to the client, and thus is more efficient
and allows the server to maintain request state.
13. The attribute which defines your jsp page as a exception handling page is
a. isExceptionPage
b. exceptionPage
c. isErrorPage
d. w. errorPage
54
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
D: Enable session tracking in the browser
18. What is the effect of executing the following JSP statement, assuming a class with name Employee
exists in class’s package?
<%@ page import = "classes.Employee" %>
<jsp:useBean id="employee" class="classes.Employee" scope="session"/>
<jsp:setPropertv name="employee" property="*"/>
A: The code does not compile as there is no properly attribute of setProperty tag.
B: The code does not compile as property attribute cannot take * as a value.
C: The code sets value of all properties of employee bean to "*".
D: The code sets the values of all properties of employee bean to matching parameters in request
object.
19. If a JSP page overrides the jsplnit() method using a declaration JSP tag, which phase of the JSP page
life-cycle generates the overridden method in the servlet?
A: page translation.
B: JSP page compilation.
C: call jsplnit()
D: call_jspService().
24. The attribute which informs container about a particular error jsp page is
55
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
A. isExceptionPage
B. exceptionPage
C. isErrorPage
D. errorPage
26. if a jsp page overrides the jspInit method using a declaration JSP tag , which phase of the jsp page
life-cycle generates the overridden method in servlet?
a) Page translation b) JSP page compilation c) call jspInit() d) call _jspService()
27. Select the correct statement about following code (Select one)
<%@page language="java"%>
<html><body>
<%
response.getOutputStream().print("hello");
out.print("World");
%>
</body></html>
a. It will print “hello World” in the output
b. It will generate compile time errors
c. It will throw runtime exceptions (java.lang.IllegalStateException: getOutputStream() has
already been called for this response)
d. It will only print “hello”
e.
28. Which is not a valid scope for javabean in JSP?
a) Page b) session c) request d) global
30. Which of the following statements is true regarding the scope of “request” in JSP?
a. Objects with request scope are accessible from pages processing the same request where they
were created.
56
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
b. All references to the object shall be released after the request is processed: in particular if the
request is forwarded to a resource in the same runtime , the object is still reachable.
c. References to the objects in request scope are stored in a request object.
d. All of the above.
31. Which of the following statements makes your compiled JSP page implement the
SingleThreadModel interface?
a. <%@ page isThreadSafe="false" %>
b. <%@ page isThreadSafe="true" %>
33. When using a JavaBean to get all the parameters from a form, what must the property be set to (???
in the following code) for automatic initialization?
<jsp:useBean id="fBean" class="govi.FormBean" scope="request"/>
<jsp:setProperty name="fBean" property="???" />
<jsp:forward page="/servlet/JSP2Servlet" />
a. *
b. All
c. @
d. =
34. Choose the statement that best describes the relationship between JSP and servlets:
a. Servlets are built on JSP semantics and all servlets are compiled to JSP pages for runtime usage.
b. JSP and servlets are unrelated technologies.
c. Servlets and JSP are competing technologies for handling web requests. Servlets are being
superseded by JSP, which is preferred. The two technologies are not useful in combination.
d. JSPs are built on servlet semantics and all JSPs are compiled to servlets for runtime usage.
35. What alternatives exist to embedding Java code directly within the HTML markup of your JSP page?
a. Moving the code into your session manager.
b. Moving the code into scriptlets.
c. Moving the code into JavaBeans and servlets
d. Moving the code into a transaction manager
36. What is the initial contact point for handling a web request in a Page-Centric architecture?
57
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
a. A JSP page
b. A JavaBean.
c. A servlet.
d. A session manager
37. Which object would you use to share user specific information between JSPs?
a. Request b. Response c. Session d. Application
38. Which of the following rules must a reusable JavaBeansTM component adhere to?
a. The Bean class must provide zero argument constructors.
b. The Bean must have a corresponding BeanInfo class.
c. The Bean must only use visible components.
d. The Bean must not be serializable.
39. Which of the following is not a standard method called as part of the JSP life cycle?
a. jspInit()
b. jspService()
c. _jspService()
d. jspDestroy()
40. If you want to override a JSP file's initialization method, within what type of tags must you declare
the method?
a. <@ @>
b. <%@ %>
c. <% %>
d. <%! %>
41. Which of the following cannot be used as the scope when using a JavaBean with JSP?
a. Application
b. Session
c. Request
d. Response
e. Page
42. What is the key difference between using a <jsp:forward> and HttpServletResponse.sendRedirect()?
a. forward executes on the client while sendRedirect() executes on the server
b. Forward executes on the server while sendRedirect() executes on the client.
c. The two methods perform identically.
58
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
44. One of the following is jsp expression
a) <%! %> b) <% %> c) <%@ %> d) <%= %>
47. Two of the following are used to call bean class setter and getter methods.
A) setAttribute b) getProperty c) getAttribute d) setProperty
49. When jsp is generated into servlet it is derived from which class
a) HttpServlet b) HttpJspBase c) HttpJspPage d) Servlet
51. For every tag encounter, a new instance of Tag Class is created.
a. True b. False
52. One of the following JSTL tag performs URL rewriting Select one:
A. url
B. aHref
C. import
D. link
55. One of the following cannot be overridden while writing JSP page
A. jspService
B. JspDestroy
C. jspInit
D. _jspService
MULTITHREADING
1. One of the following method is not executed by the programmer while writing multithreaded
applications.
A: start
B: sleep
C: join
D: run
2. Given
public class Trial extends Thread
{
public void run()throws NullPointerException
{
System.out.println("hello");
}
public static void main(String args[])
{
new Trial().start();
System.out.println(“done”);
}
}
60
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
D: it will print “done” and then throw “NullPointerException”
4. The___________ interface should be implemented by any class whose instances are intended to be
executed by a thread.
A: Serializable
B: Comparable
C: Collection
D: Runnable
7. Given
1. public class TestOne {
2. public static void main (String[] args) {
3. Thread.sIeep(3000);
4. System.out.printIn("sleep");
61
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
5. }
6. }
A: No error, prints sleep
B: Compilation error
C: Runtime Error
D: No error & no output
10. Which type of instanceof does targetObject have to pass for this to be legal while using
Thread t=new Thread(targetObject);
a) targetObject instanceof Thread
b) targetObject instanceof Applet
c) targetObject instanceof Object
d) targetObject instanceof Runnable
11. __________ are utilized to control the access to an object especially in multithreaded programming?
a) Asynchronized methods b) serialized methods c) synchronized methods d) both a and c
12. ___________ means each method in multithreaded environment doesn’t access data by multiple
threads at the same time.
a) Thread detach b) thread isolation c) thread safety d) thread lock
13. Which of the following starts the default thread available in java program?
a) System class b) main method c) static keyword d) none of these
16. 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++)
{
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. Clean compile and at run time the values 0 to 9 are printed out
d. Clean compile but no output at runtime
19. In case of class lock, non-static synchronized methods come into picture.
a) False b) true
22. One of the following method has to be invoked by the programmer in order to bring thread from born
to runnable state.
A: start
B: sleep
C: join
D: run
A. True B. false
29. One of the following methods programmer never invokes in case of multi-threading application
A. Run
B. start
C. wait
D. notify
30. We can invoke wait, notify or notify all from non-synchronized methods
A. True B. false
33. All the blocking methods i.e. sleep, wait and join can throw
A. IllegalMonitorStateException
B. InterruptedException
C. BlockingException
D. none of the above
66
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
35. What will happen?
class MyTarget implements Runnable
{
public void run()
{
System.out.println(“MyTarget run”);
}
}
public class MyApp
{
public static void main(String args[])
{
MyTarget m=new MyTarget();
Thread t1=new Thread();
t1.start(m);
}
}
37. A class which contains non-static synchronized methods or blocks is called as_________
A. Singleton
B. Synchronized
67
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
C. Thread-Safe
D. none of the above
38. _______ method makes caller thread wait till this thread die.
a. Wait
b. sleep
c. yield
d. join
MVC
1. One of the following is responsible for responding to user input and perform interactions on the data
model objects.
A: model
B: view
C: controller
D: none of them
Oops
A: 20
B: 10
68
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
C: NullPointerException
D: None of the above
5. Given
public static void main(String args[])
{
Integer i;
if(i==65)
{
System.out.println("65");
}
else if(i==0)
{
System.out.println("0");
}
else
{
System.out.println(“garbage”);
}
}
A: output “0”
B: NullPointerException
C: Compilation error
D: output “garbage”
69
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
6. Given
public class Trial
{static Double d;
public static void main(String args[])
{
if(d==0)
{
System.out.println("0");
}
else
{
System.out.println("garbage");
}
}
}
A: it will fail at runtime
B: output 0
C: output garbage
D: compiletime error
70
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
11. Which of the following methods cause the string object referenced by s to be changed?
A: s.concat()
B: s.touppercase()
C: s.repIace()
D: None of the above
12. Given
{
public static void rnain(String [] args)
{
PassA p = new PassA();
p.start();
}
void start()
{
long [] a1 = {3,4,5};
long [] a2 = fix(a1);
System.out.print(a1 [0] + a1 [1] + a1 [2] + " ");
System.out.println(a2[0] + a2[1] + a2[2]);
}
long [] fix(long [] a3)
{
a3[1] = 7';
return a3;
}
}
A: 1 2 1 5
B: 1 5 1 5
C: 3 4 5 3 7 5
D: 3 7 5 3 7 5
enum Animals
{
DOG("woof"), CAT("meow"), FISH("burbIe");
String sound;
Animals(String s) { sound = s; }
}
71
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
72
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
}
a. true
b. false
c. compiler error
d. runtime error
18. To provide access to members of the class to another class in different package which access
specifier is used?
a) Public b) protected c) private d) no modifier
22. Which string instance method would return true when invoked liked this:
a.method(b)
where a=”BUTTERfly” and b=”butterFLY”
a) equalsIgnoreCase() b) toUpperCase() c) toLowerCase() d) equals()
73
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
d. this() constructor is invoked within a constructor of a class while super() constructor is used
within the constructor of the sub class.
System.out.println(sb1==sb2);
System.out.println(sb1.equals(sb2));
System.out.println(sb1.equals(ss1));
System.out.println("Poddar".substring(3));
}
}
if(str1==str3)
{
System.out.println("str1 and str3 are
==");
}
else
{
System.out.println("str1 and str3 are
not ==");
74
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
}
if(str1.equals(str3))
{
System.out.println("str1 and str3 are
equals");
}
else
{
System.out.println("str1 and str3 are
not equals");
}
}
}
d) compilation error
28. Constructor is the class that does not provide information about, and access to, a single constructor
of a class.
a. True b. False
30. String s1=”hello”; String s2=”hello”; which one will return true
a) s1==s2 b) s1.equals(s2) c) both a and b
31. What is the correct ordering for the import, class and package declaration when found in a single
file?
75
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
a. package, import, class
b. class, import, package
c. import, package, class
d. package, class, import
76
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
A. Primitive_type
B. reference_type
C. both a and b
D. none of these
45. According to the new version of java, along with byte,short,int ,char following type is also allowed
A. Double
B. float
C. String
D. none of the above
77
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
47. Java does not support
A. pointers
B. friend_keyword
C. multiple_inheritance
D. all of the above
51. What will happen if static modifier is removed from the signature of the main method?
A - Compilation Error.
B - RunTime Error: NoSuchMethodError.
C - Program will compile and run without any output.
D - Program will compile and run to show the required output.
52. Under what conditions is an object's finalize() method invoked by the garbage collector?
A - When it detects that the object has become unreachable.
B - As soon as object is set as null.
C - At fixed intervalm it checks for null value.
D - None of the above.
54. Under what conditions is an object's finalize() method invoked by the garbage collector?
A – Just before object gets garbage collected.
B - As soon as object is set as null.
C - At fixed intervalm it checks for null value.
D - None of the above.
78
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
{
A. 1
B. 2
C. 3
D. 0
56. Which of the following is the correct syntax for suggesting the JVM performs garbage collection.
A. System.free ();
B. System.setGarbageCollection () ;
C. System.out.get () ;
D. System.gc ();
59. What will be the result of attempting to compile and run the following code?
public class test3
{
static int a;
int b;
public test3()
{
int c;
c=a;
79
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
a++;
b+=c;
}
public static void main(String args[])
{
new test3();
}
}
A. The code will fail to compile since the constructor is trying to access static members
B. The code will fail to compile since the constructor is trying to use static field “a “ before it
has been initialized.
C. The code will fail to compile since the constructor is trying to use static field “b “ before it
has been initialized.
D. The code will fail to compile since the constructor is trying to use static field “c “ before it
has been initialized.
E. The code will compile and run without any problems.
SERVLET
1. Select the correct statement
A: ServletConfig is not available inside constructor
B: servlet gets instantiated every time a new request comes.
C: programmer has to override “service()” method of parent class
D: GenericServlet is a concrete class
3. In order to retrieve existing session only [not to create new] which function should be used ?
A: getSession(true)
B: getSession()
C: getSession(false)
D: all of the above
12. Which of the following method is not used to retrieve request parameters?
A: getParameterNames()
B: getParameter()
C: getParameterVaIue()
D: None of the Above
14. Depending upon the events on servlet we can specify the following levels_____________.
A: Request level events
B: ServletContext level events
C: Only A
D: Both A and B
16. You want to use URL rewriting to support client browsers, which do not use cookies. Which method
will you use to attach the session id to a URL that is to be used for the sendRedirect() method of the
HttpServletResponse?
82
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
A: encodeURL
B: encodeRedirectURL
C: encodeSessionURL
D: encodeSessionRedirectURL
17. Given that the service() method of a typical servlet is multithreaded, which one of the following
issues does NOT need to be addressed in a servlet's implementation?
a. Concurrent access to shared resources
b. Concurrent access to local variables
c. Concurrent access to static variables
d. Concurrent access to instance variables
18. _______ is the object used for reading “init” or “config” parameters.
A) ServletContext b) ServletConfig c) RequestDispatcher
21. Following methods are the part of servlet lifecycle. [Choose 3 correct answers]
A) Start b) init c) stop d) service e) destroy
28. Following interface is used to either forward or include other web resource.
A) Servlet b) RequestDispatcher c) ServletConfig d) HttpResponse
29. Besides the cookie object which other object is also required to create a cookie on the browser?
a. Request
b. Response
c. Session
d. Application
32. Your web application named bank uses “WelcomeServlet”. Where will u store
“WelcomeServlet.class”?
a. bank/WEB-INF/classes
b. bank/WEB-INF/lib/classes
c. root/WEB-INF/lib
d. bank/WebContent/lib/classes
33. What method can be used to retrieve value of the request parameter being sent as a part of the
request by client?
a. Use the method “HttpServletRequest.getParameter(string name) which will return String
form.
b. Use the method “HttpServletRequest.getParameterValues() which will return array of String
values.
c. Use the method “HttpServletResponse.getValues()” which will return array of string values.
d. There is no direct support in servlet api.
84
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
34. Which of these true about deployment descriptor?
a. The order of elements in deployment descriptor is important. The elements must follow a specific
order.
b. The servlet-mapping element if present must be defined within “servlet” element.
c. The elements of deployment descriptor are not case insensitive.
d. The web-app element must include the servlet element.
35. If the HTTP error 500 is generated by your servlet, you do not want to show the “Internal Server
Error” page to the client. Instead, you want a custom error page to be displayed. What is the best way to
accomplish this?
a. Forward the user to the error page using HttpServletResponse.sendRedirect() method.
b. Forward the user to the error page using RequestDispatcher.forward() method.
c. Specify the mapping of the error-code 500 and the error-page in the deployment descriptor.
d. It is not possible to accomplish this.
36. Which of the following should not be used to share data between servlets in a distributed web
application?
a. Attributes of ServletContext
b. Enterprise JavaBeans
c. Attributes of HttpSession
d. Database
37. You want to use URL Rewriting to support client browsers which do not use cookies. Which method
will you use to attach the session id to a url that is to be used for the “sendRedirect()” method of the
HttpServletResponse?
a) encodeURL b) encodeRedirectURL c) encodeSessionURL d) encodeSessionRedirectURL
39. A user types the URL http://www.cdac.in which Http request gets generated?
a. GET method
b. POST method
c. HEAD method
d. PUT method
40. Which object is used to forward the request processing from one servlet to another?
a. ServletContext
b. ServletConfig
c. RequestDispatcher
d. ResponseDispatcher
85
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
41. The method getWriter() returns an object of type PrintWriter. This class has println() method to
generate output. Which of these classes define the getWriter method? Select the one correct answer.
a. HttpServletRequest
b. HttpServletResponse
c. ServletContext
d. ServletConfig
43. Which of the following method is not used to reterive request parameters
A: getParameterNames()
B: getParameter()
C: getParameterVaIue()
D: None of the Above
48. In order to make Servlet entry inside DD, we need to mention _______.
A. Servlet-Class
86
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
B. Servlet-name
C. URL-pattern
D. All of these
53. DD is _______.
A. Config.xml
B. None of these
C. Webconfig.xml
D. Web.xml
56. Request Dispatcher reference can be used for forward as well as include
A. False B. True
88
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
B. ServletConfig
C. ServletContext
D. None of these
70. If u want to ensure servlet loading even before first request u need to use
A. <start-on-load>
B. <load-on-startup>
C. <load-on-start>
D. none of these
SOCKET PROGRAMMING
1. Which of the following class allows Tcp Server to wait for client on a particular port?
A: InetAddress
B: ServerSocket
C: Socket
D: none of the above
2. One of the following port range is valid for Network programming in java
A: 1 to 65535
B: 1023 to 65535
C: 1024 to 65535
D: 0 to 1023
89
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
3. Which one is used to send packet over the network in case of UDP?
A: DatagramPacket
B: Socket
C: DatagramServer
D: DatagramSocket
6. Which of the following class allows UDP Server to wait for client on a particular port?
A: InetAddress
B: DatagramSocket
C: DatagramPacket
D: none of the above
90
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
10. The class which is used to send the packet in case of UDP is
A. Socket
B. UDPSocket
C. UserDatagramPacket
D. UserDatagramSocket
16. _______ class is used to make server wait for client request in TCP.
A. Socket
B. ServerSocket
C. SocketInputStream
D. none of these
18. Marshalling is
A. Converting packets into data
B. converting data into packets
C. converting bytes into character
STRUTS
1. Following is the main controller in struts2 framework
A: FilterDispatcher
B: ActionServlet
C: FilterServlet
D: FilterController
4. In action tag, when method is not specified, which method is by default considered?
A: run
B: actionexecute
C: execute
D: perform
5. One of the following is the map in OGNL to retrieve any type of attribute
A: request
B: application
C: page
D: attr
6. Which is the interface used if you want to access “request” object in your action class?
A: ServletRequest
B: HttpServletRequest
C: ServletRequestAware
D: RequestAware
92
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
7. Action methods must return
A: String
B: int
C: boolean
D: it can return any type
10. EL maps
pageScope Scoped variables from page scope
13. Interceptor does __________&________processing of request and invokes the action classes.
A: pre, post B: before, after C: get, post D: None of the above
19. _____________ is the interceptor stack available by default to every sturts application.
A) execAndWait b) validateStack c) defaultStack
21. In action tag, when method is not specified ___________ is the by default method considered.
A) run b) execute c) actionExecute d) perform
22. We can forward the request from one action class to another. True
94
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
25. Action method has to return
a) String b) int c) Boolean d) it can return any type
29. __________ is the interface used if you want to access “request” object in your action class.
A) ServletRequest b) HttpServletRequest c) ServletRequestAware d) RequestAware
30. If the action name is “AddAction”, the validation file name should be ______________
a) AddAction-validation.xml
b) AddAction-validator.xml
c) AddAction_validation.xml
SPRING
1. Spring controller can be defined using annotation
a) @Bean
b) @Component
c) @Controller
d) none of the above
3. The advice functionality takes place after the advised method completes, regardless of the outcome:
a) after-returning
b) After
c) after-throwing
d) None of the above
95
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
4. In Spring framework by default the scope of bean is
A. Prototype
B. Request
C. Session
D. Singleton
7. Join points can be method calls, constructor invocations, exception handlers, or other points in the
execution of a program.
a) true
b) false
8. When a lazy-initialized bean is a dependency of a singleton bean that is not lazy-initialized, the
ApplicationContext creates the lazy-initialized bean at startup
a) True
b) False
9. Spring DAO framework converts checked exception into unchecked exception. The name of
unchecked exception is________
a) RuntimeException
b) SQLException
c) DataAccessException
d) none of the above
11. One of the following helps controller in resolving a particular view component.
96
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
a) ModelAndView
b) HandlerMapping
c) ViewResolver
d) DispatcherServlet
15. In order to use @Component annotation for a bean u need to add following tag in Spring bean
configuration file.
a) <context:component-scan>
b) <auto:component-scan>
c) <context:bean-scan>
d) None of the above
97
Vidyanidhi Info Tech Academy
Vidyanidhi Info Tech Academy
PG DAC JAVA Question Bank
A: extend JFrame, inside main instantiate JApplet
B: extend JApplet, inside main instantiate JFame
C: extend JFrame as well as JApplet
D: none of these
98
Vidyanidhi Info Tech Academy