26. Valid declarations(check box)
Interface iface{}
Public class cface implements{}
Public class base{}
Public class sub extends base{
PSVM{
Base b=new base()
Sub b1=new sub()
Object ob1=new object()
Cface ob2=new cface()
}
a. b=b1
b. b1=b
c. ob1=ob2
d. ob2=ob1
27.given some coding regarding jdbc and ask in which line we have error?
28. which are not true about custom tags?
a. custom tags are not nested
I don’t remember other options
29. how you commit your own transaction
a….=transaction .setcommit(Boolean flag)
some options like this
30.Each process has at least one thread
a. true
b. false
31. which of the following are true about process
a. process has separate memory space
b. they have hold of some private resources…..
c. ………….
d. all the above
32.what is the output?
base class:
{
method p1()
{
SOP("P.print S1")
}
method p2()
{
SOP("P.print S2")
}
method p1p2(){
p1()
p2()
}
}
derived class:
{
method p1()
{
SOP("Q.print S1")
}
method p2()
{
SOP("Q.print S2")
}
PSVM(){
base b= new derived();
b.p1p2()
}
}
a. P.print S1 P.print S2
b. Q.print S1 Q.print S2
c. P.print S1 Q.print S2
d. Q.print S1 P.print S1
33. What is output of the program?
Public class A{
A()
{
Class B
SOP(“I’m in no arg constructor”)
}
A(int i)
{
Class B
SOP(“I’m in a arg constructor”)
}
New B()
}
Public class C{
Psvm(){
A a= new A(5)
}
a…….error in definition of class B
b. ………error in …
c. Compiles and print I’m in a arg constructor….
d. ………
1. Avg (age) =? Ans 10
2. When joining 2 tables Ans: Increasing R to L
3. To count the number of rows in a table Ans: count (*)
4. Right Join – Ans: All values in second table even if no match from first table
5. Can JDBC-ODBC driver support multithreading..? Ans: noooooooooooooo naheeeeeeeeeeee kevvvvvvvvvv
6. If connection is not fully compliant what happens? Ans: Driver Manager won’t register it.
7. While (rs.next ()){
Integer x=s.getInt(c);
---
---
}
Ans: No error
8. How to make servlet implement single thread model.
Ans: By setting isThreadsafe=False
9. Difference Between <%@Include %> and <jsp=include>
Ans: <%@Include %> - related to compile time
<jsp=include> - related with request time
10.Which two are equal
Ans: <jsp:scriplet>---------;</jsp:scriplet> and <%--------;%>
11.Steps for using JDBC
Ans: All of the above
12. what method used to initiate servlet
Ans: void init(ServletConfig)
13.When to use forward and when to use redirect.
Ans: redirect – client side -- forward server side
14. where is the connection closed ..?
Ans: In the finally() method
15.How to maintain sessions:
Ans: save in secret field,url rewriting,cookies … In short All of the above ;)
16.Can inner classes implement interface and extend another class..
Ans : Nooo
17. Transient can be used ….
Ans: Instance variables
18.Ans:Non static methods can over ride Non Static methods
19.int i=o;
Boolean b = false
If(b&&(i++>0))
{
empty
}
System.out.println(i);
Ans: 0
20. boolean b = false
String s
S = (b=!b)?hello:Hello: (b=!b)?world:World
Ans: HelloWorld (Not sure exactly but I think so)
21.What identifies in an action uniquely..?
Ans: path
22. In init parameter ………..
Ans:Application
23.In MVC perspective , struts provides ..?
Ans: Controller
24. If methods in older versions of java are used then what happens ..?
Ans: deprecated
25. whats a correct interface name..?
Ans: ModelInterface
26.Issues in sublassing.
Ans: All of the above.
27. Initial attribute values can be set from deployment descriptor.
Ans False
28. 10 Null and 5 Non Null values count(*) returns Ans:15
29.whats the output…?
<html>
<body>
Value is
<%= ” ” %>
</body></html> Ans: value is
30.When does JVM exit ..?
Ans: System.exit() is called
31.Ans: Arrays in java are objects
32. Something about flush…
33. Relating to implicit objects
34.What represents an identifier name for a resource but not have to locate/path to it ..?
Ans:URI
35.Acces features represent which features of OOP ..?
Ans: Encapsulation ….
2)each process must have a thread .true or falseeee?
3)driver manager is used to
a)manage all connections.
b)to manage jdbc drivers
4) which of the following will allow control flow
a)try wit handled exception
b)try wit unhandled exception
c)all above
d)try wit no xceptionnnnnnnnn
5)inheritance disadvantage
6)count ,avg questions repeated
7)inner join
9)difference between redirect and forword
10)latest version of JSP? 2.1
11)
Given
Float i=4.4f,j=8.5f;
sop((-i==~i+1)+”,”+(-j==~j+1));
wat is output?
a)compilation error
b)true,false
c)false,true
d)true,true
12)which is used to identify the resource but not tell how to reach that resource?
a)URI
b)URL
c)URI or URL
1. class A{
pvsm(string[] args){
char c=97;
sysout(c);
}}
A. 97
B. A
C. Compilation error
D. c
2. Command line argument “ Java Test this is a program”
Class A{
Pvsm(string[] args){
Sysout (args[1]);
}}
A. is
B. this
C. this is aprogram
D. none
3. Valid array declaration(check box)
i)string [][]b;
ii)string []i[];
iii)string i[][];
iV)string i[5][];
. 4. When using join in sql which of the following is fast to load..
i) in increasing order from right to left
ii) in descending order from right to left
iii) in increasing order from left to right
iv) in descending order from left to right
5. Jdbc:odbc driver supports multi threading..
a. true
b. False
6. Name of application resource file is set by the servlet init_param named.
e. application resources
f. application
g. resources
h. messages
7. Which is not an HTTP method
m. Retrieve
n. Post
o. Head
p. Get
8. <html><body>The value of <%=” “%>…what will print
The value of
9. How to find the different values in sql
Ans: Distinct
10. From a MVC perspective, Struts provides the
a. model
b. view
c. controller
11. Which are not true about custom tags?
a. custom tags are not nested
I don’t remember other options
12. One question on JSP flow to find the wrong statement
1. The JSP converts to HTML form
2. All the above
3. Translation to loading and them giving response (Not sure abt this line, But this is a correct statement.)
13. Which option is correct to read the binary file named asd.zip?
a)config.getresourceasstream(/web.inf/asd.zip)
b)config.inputstream(“asd.zip”);
c)context.inputstream(“asd.zip”);
d) context.getresourceasstream(/web.inf/asd.zip)
14. Constructors allow inheritance : True or false
15. Where is the connection closed ..?
Ans: In the finally() method
16. The validating init-param of the ActionServlet is used to
A. | Bypass calls to the ActionForm validate method |
B. | Bypass validation of the Struts configuration file |
C. | Generate an error message if an unknown message key is used |
Answer: B is correct. The default validating=true setting forces a validating XML parser to be used
17. To specify an ActionMapping to use when a request doesn't match any other mapping, you can
A. | Use an asterisk for the path property |
B. | Set the "default" property of the mapping to "true" |
C. | Set the "unknown" property of the mapping to "true" |
D. | Set the "missing" init-param of the ActionServlet to the mapping's path |
To specify an ActionMapping to use when a request doesn't match any other mapping, you can C is correct! Answer: C is correct.
18. To localize Validator forms, you can
i. Create separate configuration files for each locale
ii. Specify a locale for a form-set
options:
a. Either i or ii
b. Neither i or ii
c. Only i
d. Only ii
20. Declaration of a method in a JSP
a. <%@ method() %>
b. <% method() %>
c. <%! Method() %>
d. <%! Method(); %>
21. Which are all the valid methods in jsp?
a. jspInit()
_jspService()
jspDestroy()
b. _JSPInit()
_JSPService()
c. -JSPInit()
_JSPService()
_JspDestroy()
_JSPdodelete()
_JSPdoget()
_JSPdopost()
22. A code is given …in that he asks, at line 4 of the code which method suits the best
Code contains names of
Elephant
Dog etc upto 4 names …So choose the method which suits
a. getparameterNames()
b. getparametervalues()
c. getparameter()
d. getvalue()
23. abstract class MineA{
string str;
method();{
Class Mine extends MineA{
Pvsm(){
Int [] s = new int [5];
Sysout(some value);
}}
Ans: class Mine should be declared abstract –Compilation error.
24. Boolean b = false
String s;
S= (b= !b)? (b= !b): Hello: hello : (b= !b)? World: world
a. Helloworld
b. helloworld
c. Hello
d. Hello
25. Choose the statement that best describes the relationship between JSP and servlets:--D
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. |
86) class parent{
void method(){
sysout(“parent”)
}
}
class child extends parent{
void method(){
sysout(“Child”)
}
}
Parent obj new child();
What is the output?
87) Preparestatement
88) distinct in sql
89) using forward in jsp
90) redirect and forward in servlet
91) servlet context
92) jsp in relation to servlet
93) if the package name is not known
106) a)config.getresourceasstream(/web.inf/asd.zip)
b)config.inputstream(“asd.zip”);
c)context.inputstream(“asd.zip”);
d)context.getresourceasstream(/web.inf/asd.zip)
146) If methods in older versions of java are used then what happens ..?
Ans: deprecated
147) what’s a correct interface name..?
Ans: ModelInterface
148) Issues in subclassing.
Ans: All of the above.
149) Initial attribute values can be set from deployment descriptor.
Ans False
150) what’s the output…?
<html>
<body>
Value is
<%= ” ” %>
</body></html> Ans: value is
151) When does JVM exit ..?
Ans: System.exit() is called
1) How can you return the number of records in a table?
1. Which of the following types of inheritances do java support?
a.single inheritance
b.multiple inheritance
c.multilevel inheritance
d.hybrid
e.Only single and multiple inheritance
2.) import library.*
Public class Myprogram{}
What should be the name of the java file containing this program?
a.Library.java
b.Myprogram.java
3.) which of the following are the valid comment stmt in java?
a.//
b./**/
c.!---!
d./** **/
4)An object should never directly manipulate the internal data of another object.
This reflects which of the following..
a.encapsulation
b.abstraction
c.polymorphism
d.inheritance
5) public final void amethod(){
Sysout(“amethod”);
Public class Fin extends Base{
Public static void main(String args[]){
Base b=new Base();
b.amethod();}}
Wt is the o/p
a.compile time error caused because final methods must be declared as final itself
b.Compile time error because cannot inherit from a cls with final methods.
c.Runtime error because base is not defined as final.
d.amethod is printed.
5.) class A{
Static void m(){
Sysout(“A”);}}
Class B extends A{
Static void m(){
Sysout(“B”)}}
Class C extends B{
Static void m(){
Sysout(“C”);}}
Class D{
Public static void main(String[] args)
{
C c=new C();
c.m();
B b=c;
b.m();}}
wt s de o/p?
a.AAA
b.ABC
c.CBA
d.CCC
6.) Base class has a method, void method(){}
Which are legal prototypes in a derived cls of this cls.
a.void method(){}
b.int method(){return 0;}
c.void method(int i){}
d.private void method(){}
7.)import java.util.*
Public class Problem
{
Public static void main(String[] args){
Timer timer=new Timer();
Timer.schedule(new TimerTask){
Public void run(){
Sysout(“Exiting”);
Timer.cancel();}}
Sysout(“In 5 sec this appln will exit”);
What will u do to make it compile?
a.Add final infront of the declaration of time variable.
b.A nested class declared within a method has accesss to any final,local variables in scope.
c.Change the ‘s’ in the last Sysout to ‘S’.
d.Change the return type in the public void run method to int.
8.) Which is responsible for java’s platform independent
a.JRE
b.JVM
c.JavaAPI
d.javap
9.)class MyBase{
Public MyBase(int i){}}
Public class Myover extends MyBase{
Public static void main(String args[]){
Myover m=new Myover(10);}
Myover(int i){
Super(i);}
Myover(String s,int i){
This(i);}}
Which could be in include in the Myover(String s,int i) method?
a.Myover m=new Myover();
b.super();
c.this(“Hello”,10)
d.MyBase b=new MyBase(10)
10.)Name the access modifier which when used with a method,makes it available to all the classes in the same package and to all the sub classes of the class?
a.protected
b.private
c.public
d.default
11.)Which are true?
a.Java does not supports inheritance through pointers. T
b.java supports classes but does not support structure,union T
c.java supports multiple inheritance. F
d. to some extent the interface feature provides the desirable features of multiple inheritance to a java programT
12.) import java.io.*
Class Base{
Public void amethod() throws FileNotFoundException{}}
Public class ExcepDemo extends Base{
Public static void main(String argv[]){
ExcepDemo e=new ExcepDemo();}
Public void amethod(){}
Protected ExcepDemo(){
Try{
DatInputStream din= new DataInputSream(system.in);
Sysout(“passing’)
Din.readByte();
Sysout(“couting”);
This.amethod();}
Catch(IO Exception ioe){}}}
Wt s de o/p
a.compile time error due to protected constructor.
b.Compile time error due to method not declared exception
c.Runtime error due to amethod not dec.. exeption
d.compile and run with o/p of passing and continuing
13.)sub class methods can access superclass members /attributes at all time
a.True b.False
14.) class A{
Public int getNumber(int a){
Return a+1;}}
Class B extends A{
Public int getNumber(int a){
Return a+2;}
Public static void main(S args[]){
A a= new A();
Sysout(a.getNumber(0));}
1. Volatile modifier can be serialized.- True or false.
2. Length of datatype int:
a. 64 bits
b. 32 bits.
c. 16 bits.
d. 8 bits
3.something related to map-snippet
Map.put(“ ….. “);
Map.put(“ ….. “);
Ans: compilation error (I think so)
4. some sevlet code:
<name=animals >
<option1= “cat”….>
</select>
8. related to interface- check box
a. cannot be done in java
b. it always allows only static methods
c. it always allows only public methods…………
9. related to struts everything from that website.
10. There will be three codes for jdbc connection which of the three is valid?
i)in the code.. finally{
con.close
}
ii) con.close inside try
iii) con.close inside exception
11.given connection prog asked abt
1. password should be encrypted
2. driver name url wrong
3. incorrect sequence retrival
4…………….
1) What is the output of the following program?
public class SampleJava
{
public static void main(String argv[]){
int i=10;
Method(i,i=5);
}
public static void Method(int a,int b)
{
System.out.println(a+" "+b);
}
}
Output: 10 5
2) Implicit object not available in JSP
a. application
b. session
c. exception
d. config
Answer: exception
Reference: JSP provides certain Implicit Objects listed below.
Object | Of Kind |
Out | JSP writer |
Request | HttpServletRequest |
Response | HttpServletRespose |
Session | HttpSession |
Application | ServletContext |
Config | Sevlet Config |
Page | Object |
PageContext | Page Context => is responsible for generating all other implicit objects. |
3) what will be the output?
public class SampleJava
{
public static void main(String argv[]){
int i='a';
System.out.println(i);
}
}
Output: 97
4)What will be the output ?
public class SampleJava
{
public static void main(String argv[]){
String s1="one";
String s2=new String("one");
if(s1.equals(s2))
System.out.println("equals");
boolean b1=new Boolean(true);
boolean b2=new Boolean(true);
if(b1==b2)
System.out.println("boolean equals");
}
}
Output: equals Boolean equals
5) Similarity between abstract class and interface
Answer: Neither abstract class nor interface can be instatiated
7) Consider a 3rd party class that isn’t directly sortable, which interface is used to make sorting
a. Comparator (I had choosen this choice.. please check) Answer
b. Sorter
c. comparable
d. Sortable
8) Which of the following is a valid declaration for Date?
a. <% Date d= new Date();%>
b. <%! Date d=new Date();%> Answer
c. <%= Date d=new Date();%>
d. ….
10) what is the method used when session object should never be invalidated by servlet container?
a. setTimer(-1);
b. SetMaxTime…
c. ..setmaxinactiveinterval(-1)(ans)