Вы находитесь на странице: 1из 13

1) Which is a valid method signature in an interface?

a) private int getArea();


b) protected float getVol(float x);
c) public static void main(String [] args);
d) boolean setFlag(Boolean [] test []);
Ans : d
2)

Given the code below:


interface MyInterface
{
void doSomething ( ) ;
}
class MyClass implements MyInterface
{
// xx
}

Choose the valid option that can be substituted in place of xx in the MyCla
ss class.
a) public native void doSomething( );
b) void doSomething( ) { /* valid code fragments */ }
c) private void doSomething( ) { /* valid code fragments */ }
d) protected void doSomething( ) { /* valid code fragments */ }
Ans : a

3)

Which statement is true about accessibility of members?


a) Private members are always accessible from within the same package.
b) Private members can only be accessed by code from within the class of
the member.
c) A member with default accessibility can be accessed by any subclass o
f the class in which it is defined.
d) Package/default accessibility for a member can be declared using the
keyword default.
Ans : b
4)

package com.test.work;
public class A
{
public void m1()
{
System.out.print("A.m1, ");
}
protected void m2()
{
System.out.print("A.m2, ");
}
private void m3()
{
System.out.print("A.m3, ");
}
void m4()
{

System.out.print("A.m4, ");
}
}
class B
{
public static void main(String[] args)
{
A a = new A();
a.m1(); // 1
a.m2(); // 2
a.m3(); // 3
a.m4(); // 4
}
}
Assume that the code appears in a single file named A.java.
What is the result of attempting to compile and run the program?
a) Prints: A.m1, A.m2, A.m3, A.m4,
b) Compile-time error at 2.
c) Compile-time error at 3.
d) Compile-time error at 4.
Ans : c

5) Which of these array declaration statements is not legal?


a) int[] i[] = { { 1, 2 }, { 1 }, {}, { 1, 2, 3 } };
b) int i[][] = new int[][] { {1, 2, 3}, {4, 5, 6} };
c) int i[4] = { 1, 2, 3, 4 };
d) int i[][] = { { 1, 2 }, new int[ 2 ] };
Ans : c

6) Which one of the below expression is equivalent to 16>>2 ?


a) 16/4
b) 16/2
c) 16*2
d) 16/2^2
Ans : a

7) Given:
public class B
{
Integer x;
int sum;
public B(int y)
{
sum=x+y;
System.out.println(sum);
}
public static void main(String[] args)
{

new B(new Integer(23));


}
}
What is the expected output ?
a) The value "23" is printed at the command line.
b) Compilation fails because of an error in line 9.
c) A NullPointerException occurs at runtime.
d) A NumberFormatException occurs at runtime.
Ans : c

8) Which one of the following is legal declaration for nonnested classes and in
terfaces?
a) final abstract class Test {}
b) public static interface Test {}
c) final public class Test {}
d) protected interface Test {}
Ans : c
9) Given the following,
public class ThreeConst
{
public static void main(String [] args)
{
new ThreeConst();
}
public void ThreeConst(int x)
{
System.out.print(" " + (x * 2));
}
public void ThreeConst(long x)
{
System.out.print(" " + x);
}
public void ThreeConst()
{
System.out.print("no-arg ");
}
}
What is the result?
a) 8 4 no-arg
b) no-arg 8 4
c) Compilation fails.
d) No output is produced.
Ans : d
10) Given the following,
public class ThreeConst
{
public static void main(String [] args)
{
new ThreeConst(4L);
}
public ThreeConst(int x)

{
this();
System.out.print(" " + (x * 2));
}
public ThreeConst(long x)
{
this((int) x);
System.out.print(" " + x);
}
public ThreeConst()
{
System.out.print("no-arg");
}
}
What is the result?
a) 4 8
b) 8 4 no-arg
c) no-arg 8 4
d) Compilation fails.
Ans : c

11)

class A
{
public static void main (String[] args)
{
Error error = new Error();
Exception exception = new Exception();
System.out.print((exception instanceof Throwable

) + ",");
System.out.print(error instanceof Throwable);
}
}
What is the result of attempting to compile and run the program?
a) Prints: false,false
b) Prints: false,true
c) Prints: true,false
d) Prints: true,true
Ans : d
12) Given the following code in the 3 java files:
NewException.java
----------------class NewException extends Exception
{
}
Welcome.java
-----------class Welcome
{
public String displayWelcome(String name) throws NewException
{
if(name == null)
{

throw new NewException();


}
return "Welcome "+ name;
}
}
TestNewException.java
--------------------class TestNewException
{
public static void main(String... args)
{
Welcome w = new Welcome();
System.out.println(w.displayWelcome("Ram"));
}
}
What is the result on compiling and executing it ?
a) Compiles successfully and displays Ram when TestNewException
is executed.
b) Runtime exception occurs on executing the class TestNewExcept
ion.
c) Compilation of Welcome.java fails.
d) Compilation of TestNewException.java fails
Ans : d // When throws comes in method it should be handled...
13) Which of the following is legal?
a) for (int i=0, j=1; i<10; i++, j++) { }
b) for (int i=0, j=1; i<10; i++; j++) { }
c) for (int i=0, j=1; i<10,j<10; i++, j++) { }
d) for (int i=0, float j=1.0; ; i++, j++) { }
Ans : a
14) Given the following code:
public class JavaRunTest
{
public static void main (String[] args)
{
int i = 0, j = 8;
do
{
if (j < 4)
{
break;
}
else if (j-- < 7)
{
continue;
}
i++;
} while (i++ < 5);
System.out.print(i + "," + j);
}
}
What is the result of attempting to compile and run the program?

a)
b)
c)
d)

Prints:
Prints:
Prints:
Prints:

5,4
6,5
6,4
5,7

Ans : c
15) 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 s
ubclasses.
d) Private methods of a superclass cannot be overridden in subclasses.
Ans : d
16)

abstract class AbstractIt


{
abstract float getFloat();
}
public class Test1 extends AbstractIt
{
private float f1 = 1.0f;
private float getFloat()
{
return f1;
}
public static void main(String[] args)
{
}
}
a)
b)
c)
d)

Compilation error at line no 5


Runtime error at line 8
Compilation error at line no 8
Compilation succeeds

Ans : c

17) Given:
public class TestOverload
{
public void process()
{
}
public String process()
{
return "hello";
}
public float process(int x)
{
return 67.5f;
}
}
What is the result?

a)
b)
c)
d)

An exception is thrown at runtime.


Compilation fails because of an error in line 10.
Compilation fails because of an error in line 6.
Compilation succeeds and no runtime errors with class TestOverload oc

cur.
Ans: c
18) Which of the following is a valid initialization ?
a) boolean b = TRUE;
b) float f = 27.893;
c) int i = 0xDeadCafe;
d) long l = 79,653;
Ans : c
19) What is the result of compiling and executing the below code ?
public class Test
{
public static void main(String[] args)
{
byte b=127;
byte c=15;
byte a = b + c;
}
}
a) Throws runtime exception at line no 7 saying "out of range".
b) Compilation succeeds and a takes the value of 142.
c) Compilation error at line 5. Byte cant take value of 127.
d) Compilation error at line 7.
Ans : d
20) What is the
a) -128
b) -( 2
c) 0 to
d) 0 to

numerical range of char?


to 127
^ 15) to (2 ^ 15) -1
32767
65535

Ans : d
21) Given:
int index = 2;
Boolean[] test = new Boolean[3];
Boolean foo = test [index];
What is the result?
a) foo has the value
b) foo has the value
c) foo has the value
d) foo has the value

of
of
of
of

true.
false.
null.
0.

Ans : c
22) Which one of the expressions will evaluate to true if preceded by the follow
ing code?
String a = "hello";
String b = new String(a);

String c =
char[] d =
a)
b)
c)
d)
Ans : c

a;
{ h , e
(a == "Hello")
(a == b)
a.equals(b)
a.equals(d)

, l

, o

};

23) What will be the result of attempting to compile and run the following code?
public class RefEq
{
public static void main(String[] args)
{
String s = "ab" + "12";
String t = "ab" + 12;
String u = new String("ab12");
System.out.println((s==t) + " " + (s==u));
}
}
a) The program will print true true when run.
b) The program will print false false when run.
c) The program will print false true when run.
d) The program will print true false when run.
Ans : d
24) A special file which is present inside the JAR that contain information abou
t the files packaged in a JAR file is known as
a) Metafest
b) Metadata
c) Manifest
d) Manidata
Ans : c
25) Given the following code:
public class Foo
{
public static void main(String[] args)
{
System.out.println(args[1]);
}
}
If the above code is compiled and run as follows
java Foo Apples 9 8 7
a)
b)
c)
d)

What would be the output ?


java
Foo
Apples
9

Ans : d
26) Certain DML privileges are required for merge statement.Which of the followi
ng is true?

a) INSERT and UPDATE object privileges on the


T object privilege on the source table
b) INSERT,DELETE and UPDATE object privileges
e SELECT object privilege on the source table
c) SELECT,INSERT and UPDATE object privileges
e SELECT object privilege on the source table
d) SELECT,INSERT and UPDATE object privileges
e SELECT,UPDATE object privilege on the source table

target table and the SELEC


on the target table and th
on the target table and th
on the target table and th

Ans : b
27) Which datatype can be used for loop counters?
a) LONG
b) FLOAT
c) PLS_INTEGER
d) ROWID
Ans : c
28) An equijoin is a join with a join condition containing an equality operator
a) TRUE
b) FALSE
Ans : a
29) In Oracle, a sub query can be used to _________
a) Create groups of data
b) Sort data in a specific order
c) Convert data to a different format
d) Retrieve data based on an unknown condition
Ans : d
30) In J2EE, _____ are the business components that run on the server.
a) Java Beans
b) Enterprise Java Beans
c) Java Server Pages
d) Java Script
Ans : b
31) Enterprise Information System Tier is also known as
a) Client Tier
b) Applet
c) Messaging System
d) Data Tier
Ans : d
32) Consider the following HTML code
<html>
<body>
<a href=HelloServlet>HelloServlet>HelloServlet</a>
</body>
</html>
Which of the methods of HelloServlet will definitly called if the link is cl
icked?
a) doLink
b) doGet()

c) doPost()
d) doReset()
Ans : b
33) Which of the following is the syntax for JSP declaration?
a) <# ! declaration; [ declaration; ]+ ... #>
b) <% ! declaration; [ declaration; ]+ ... %>
c) <$ ! declaration; [ declaration; ]+ ... $>
d) <@ ! declaration; [ declaration; ]+ ... @>
Ans : b
34) Which of the following JSP variables is not available within a JSP expressio
n?
a) out
b) session
c) request
d) httpsession
Ans : d
35) Which of the following is NOT a standard method called as part of the JSP li
fe cycle?
a) jspInit()
b) jspService()
c) _jspService()
d) jspDestroy()
Ans : b
36) Which statement is true regarding the code snippet given below ?
<jsp:useBean id="abc" class="test.Abc" scope="page">
<jsp:setProperty name="abc" property="name" value="Wipro" />
</jsp:useBean>
a) This will create a new bean each tine it is called and se the proper
ty also.
b) This code will fail to run if abc
bean is not already present.
c) This code set the property only if the bean is newly created.
d) This code set the property only if the bean is already existing.
Ans : c
37) Which method is used to specify the content of the response is a binary fil
e?
a) setContent();
b) setBinaryOutput()
c) setContentType();
d) sendRedirect();
Ans : c
38) Which listener will get notified when an attribute to the context is added?
a) ServletRequestAttributeListener
b) ContextAttributeListener
c) ServletContextListener
d) ServletContextAttributeListener
Ans : d

39) Which method can be used to keep track of number of concurrent users?
a) ServletContextListener
b) ServletSessionListener
c) HttpSessionBindingListener
d) HttpSessionListener
Ans : d
40) Which method is defined in javax.servlet.http.HttpSessionEvent ?
a) getSession
b) getSessionId
c) getAttribute
d) setAttribute
Ans : a
41) Which of the following is a benefit of using static analyzer?
a)
b)
c)
d)

Non-Compliance to coding guidelines can be detected automatically.


Unit testing can be performed
Code coverage can be measured
can reverse engineer the code

Ans: a
42) What is the purpose of WiproStyle?
a)
b)
c)
d)

Profiling tool
Static Analyzer tool
Unit testing tool
SCM tool

Ans: b
43) WiproStyle supports which of the following graphical reports?
a)
b)
c)
d)

pie chart & area chart


bar chart & area chart
area chart & line chart
bar chart & pie chart

Ans : d
44) Which of the following violations is thrown by WiproStyle in below code sect
ion?
public class Foo
{
public void bar()
{
int x = 2;
switch (x)
{
case 2:
int j = 8;
}
}

}
a)
b)
c)
d)

Avoid Nested Blocks


Use arraylist instead of vector
Missing Switch Default
Multiple variable declaration on the same line

Ans: c
45) Which of the following violations is thrown by WiproStyle in below code sect
ion?
public interface Foo
{
public void method (); // VIOLATION
abstract int getSize (); // VIOLATION
static int SIZE = 100; // VIOLATION
}
a)
b)
c)
d)

Redundant Modifier
Trailing Array Comma
Avoid Star (Demand) Imports
SuperFinalize

Ans: a
46) Where will coverage analysis results be available?
a) Coverage view
b) Java editor as annotated markers
c) both coverage view and Java editor as annotated markers
d) None of the above
Ans: c
47) User is interested in generating test cases for 15 files out of 20. What is
the recommended way ?
a) Generate test cases for all and then delete unwanted tests
b) Select the files for which tests are not required in test configurati
on file
c) Select the files for which tests are required in test configuration f
ile
d) WiproUT does NOT support this kind of requirement.
Ans: c
48) What is the input taken by WiproUT in auto generated test cases?
a) possible Boundary values
b) only Null values
c) all possible integer values
d) all string values
Ans: a
49) What is the maximum number of test cases generated by WiproUT for a method?
a) One
b) Two
c) Any number depending on complexity of a method
d) as specified by user in Test Case Configuration window
Ans: d
50) What does Coverage analyzer in WiproUT help to identify?
a) only Uncovered code

b) only Fully covered and Uncovered code


c) Fully covered, Partially covered and Uncovered code
d) only Partially covered and Uncovered code
Ans: c

Вам также может понравиться