Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 21

Ycmou J2EE Paper - 2

[1] Which of the following statements are correct?


I. In Java, variables of type int are commonly employed to control loops and to index arrays.
II. Any time we have an integer expression involving bytes, shorts, ints and literal numbers,
the entire expression is promoted to int before the calculation is done.
Choice a
Only I is correct.
Choice b
Only II is correct.
Choice c
Both I and II are correct. (ans)
Choice d
Both I and II are incorrect.
[2] Which of the following statements are correct?
I. Java manages the meaning of the high-order bit by adding an unsigned right shift operator.
II. The Java run-time environment is free to use whatever size it wants, as long as the types
behave as user declared them.
Choice a
Only I is correct.
Choice b
Only II is correct.
Choice c
Both I and II are correct. (ans)
Choice d
Both I and II are incorrect.
[3] What will be the output of the code snippet given below?
public class Main
{
public static void main ( String[ ] args )
{
double pi, r, a ;
r = 10.8 ;
pi = 3.1416 ;
a = pi * r * r ;
System.out.println ( a ) ;
}
}
Choice a
366.436224
Choice b
366.44
Choice c

366.43
Choice d
366.430000
ans : a
[4] Which of the following is the correct statement that you will add to the code snippet
given below to print a character corresponding to value d + 1?
public class Main
{
public static void main ( String[ ] args )
{
double d = 98 ;
// Add statement here
}
}
Choice a
System.out.println ( ( char ) ++d ) ;
Choice b
System.out.println ( ( unsigned char ) ++d ) ;
Choice c
System.out.println ( ++d ) ;
Choice d
System.out.println ( ++d.ToChar ) ;

[5] Which of the following statements are correct?


I. The outcome of a left shift on a byte or short value will be long.(f)
II. When a negative byte or short value is promoted to int, the high-order bits will be filled
with 0s. (f)
Choice a
Only I is correct.
Choice b
Only II is correct.
Choice c
Both I and II are correct.
Choice d
Both I and II are incorrect
ans : d
[6] Which of the following statements are correct?
I. The operands of the arithmetic operators need not be always of numeric types.
II. We can use arithmetic operators on boolean types.
Choice a
Only I is correct.
Choice b
Only II is correct.
Choice c

Both I and II are correct.


Choice d
Both I and II are incorrect.
ans : d

[7] Which of the following expressions are correct?


I. int x = 6 ; x = !x ;
II. int x = 6 ; if ( ! ( x > 3 ) ) { }
III. int x = 6 ; x = ~x ;
Choice a
Only I and II are correct.
Choice b
Only I and III are correct
Choice c
Only II and III are correct.
Choice d
I, II and III are correct.
ans : c
[8] Which of the following statements are correct?
I. String class can be subclassed but StringBuffer class cannot be.
II. Both String and StringBuffer implement the CharSequence interface.
Choice a
Only I is correct.
Choice b
Only II is correct.
Choice c
Both I and II are correct.
Choice d
Both I and II are incorrect.
ans : b

[9] Which of the following statements are correct?


I. Vectors and other collections store only object references.
II. When an object output stream serializes an object that contains references to other
object, every referenced object is serialized along with the original object.(t)
III. Remote references point exactly to the remote objects.
Choice a
Only I and II are correct.
Choice b

Only I and III are correct.


Choice c
Only II and III are correct.
Choice d
I, II and III are correct
ans : c
[10] Which of the following statements are correct?
I. A class contains constructors that are invoked to create objects from the class blueprint.
II. Constructor declarations look like method declarations except that they use the name of
the class and have no return type.
Choice a
Only I is correct.
Choice b
Only II is correct.
Choice c
Both I and II are correct.
Choice d
Both I and II are incorrect.
ans : c
[11] Which two are true about a method-local inner class?
Choice a
It must be marked final.
Choice b
It can be marked abstract.
Choice c
It can be marked public.
Choice d
It can be marked static.
ans : b
[12] Which of the following method is not available in thread class?
Choice a
suspend()
Choice b
wait()
Choice c
sleep().
Choice d
join()
ans : b
[13] Which constructs an anonymous inner class instance?

Choice a
Runnable r = new Runnable() { };
Choice b
Runnable r = new Runnable(public void run() { });
Choice c
Runnable r = new Runnable { public void run(){}};
Choice d
System.out.println(new Runnable() {public void run() { }});
ans : d
[14] Which of the following statements are correct?
I. Object-oriented programming is a method of programming based on a hierarchy of classes.
I Object-oriented programming is a method of programming based on a well-defined and
cooperating objects.
Choice a
Only I is correct.
Choice b
Only II is correct.
Choice c
Both I and II are correct.
Choice d
Both I and II are incorrect.
ans : c
[15] class B
{
B(String s) { }
B() { }
}
class Bar extends B
{
Bar() { }
Bar(String s) {super(s);}
void zoo()
{
// insert code here
}
}
which one create an anonymous inner class from within class Bar?
Choice a
B f = new B(24) { };
Choice b
B f = new Bar() { };

Choice c
Bar f = new B(String s) { };
Choice d
B f = new B.Bar(String s) { };
ans : b
[16] Which of the following can not be override?
Choice a
class
Choice b
class member functions
Choice c
constructor
Choice d
destructor
ans : c
[17] Polymorphism is a feature that allows one _______ to be used for a general class of
actions.
Choice a
function
Choice b
class
Choice c
package
Choice d
interface
ans : d
[18]
Which of the following statement is correct about interfaces?
Choice a
An interface is a reference type, similar to a class that can contain only constants, method
signatures, and nested types.
Choice b
Interfaces cannot be instantiated.
Choice c
Interfaces can only be implemented by classes or extended by other interfaces.
Choice d
All of the above
ans : d
[19] Which of the following statement is correct?
I. A package cannot be renamed without renaming the directory in which the classes are
stored.
II. Any classes or .class files that are the part of a package must be stored in the directory
having

the same name as that of the package.


Choice a
Both I and II are correct.
Choice b
Both I and II are incorrect.
Choice c
Only II is correct.
Choice d
Only I is correct
[20] Which of the following is true ?
Choice a
Unlimited data transfer can be done using POST method
Choice b
Data is visible in Browser URL when using POST method
Choice c
When large amounts of data transfer is to be done, GET method is used.
Choice d
None of above
ans : a
[21] Which of the following statement is correct about the program given below?
interface A1
{
int i = 5 ;
public void fun( ) ;
}
class B1 implements A1
{
int i = 7 ;
public void fun( )
{
System.out.print ( " i " + ++ i ) ;
}
}
class Test
{
static void fun( )
{

A1 C = new B1( ) ;
C.fun( ) ;
}
public static void main ( String args[ ] )
{
fun( ) ;
}
}
Choice a
Above program will print the output: i 6.
Choice b
Above program will report error(s) on compilation.
Choice c
Above program will print the output: i 8
Choice d
Above program will report run time error.
ans : c
[22]
The object created after occurrence of an exception is known as _________ object.
Choice a
exceptional
Choice b
exception
Choice c
Error
Choice d
exception handling

[23] Which of the following statements are correct?


I. We cannot implement our own collection.
II. It is allowed the integration of standard arrays into the collections framework.
Choice a
Only I is correct.
Choice b
Only II is correct.
Choice c
Both I and II are correct.
Choice d
Both I and II are incorrect
ans : b
[24] Which of the following statements are correct?

I. Algorithms operate on collections.


II. Algorithms are defined as static methods within the Collections class.
Choice a
Only I is correct.
Choice b
Only II is correct.
Choice c
Both I and II are correct.
Choice d
Both I and II are incorrect.
ans : b
[25] Which of the following statements are correct?
I. The typessafe Java enum constants replaces the set of primitive constants with a set of
static final object references encapsulated in a class that restricts further instantiation.
II. We cannot discard the enumeration object once used.
Choice a
Only I is correct.
Choice b
Only II is correct.
Choice c
Both I and II are correct.
Choice d
Both I and II are incorrect.
ans: a
[26] Which of the following provides a way for you to communicate the type of a collection
to the compiler, so that it can be checked?
Choice a
Collection
Choice b
Generics
Choice c
Wildcards
Choice d
Enums
ans : b
[27] Why beans are used in J2EE architecture instead of writing all the code in JSPs ?
Choice a
Allows separation of roles between web developers and application developers

Choice b
Allows integration with Content Management tools
Choice c
Allows integration of roles between web developers and application developers
Choice d
Allows separation of Content Management tools
ans : a
[28] When enabling your JAVA EE server application with SSL, which of the following
must occur?
Choice a
The certificate be issued by a third-party Certificate Authority, I.e. Verisign.
Choice b
The certificate be signed either by a Certificate Authority or self-signed.
Choice c
The Sun cryptographic provider package be installed in your JVM.
Choice d
An offline key exchange be done with the client prior to SSL communications.
ans : b
[29] What will be the output of the code snippet given below?
class Main
{
enum Level
{
NOVICE, MEDIUM, EXPERT ;
public void checkLevel ( Level l1, Level l2 )
{
System.out.println ( l1.toString( ).length( ) + l2.toString( ).length( ) ) ;
}
}
public static void main ( String[ ] args )
{
Level level = Level.NOVICE ;
level.checkLevel ( level, Level.EXPERT ) ;
}
}
Choice a
l2

Choice b
l1
Choice c
11
Choice d
12
ans : d
[30] Which of the following statements are correct?
I. We can match the pattern against another sequence using Pattern class.
II. The Pattern class can define constructors.
Choice a
Only I is correct.
Choice b
Only II is correct.
Choice c
Both I and II are correct.
Choice d
Both I and II are incorrect.
***Sorry some question answer is not their..
Please share this blog with your friends.
Thanks.

[1] Which of the following statements are correct? I. The long data type is the
most versatile and efficient type. (true)
II. Data type determines behavior and not size. (false)
Choice a **
Only I is correct.
Choice b
Only II is correct.
Choice c
Both I and II are correct.
Choice d
Both I and II are incorrect.
[2] Which of the following statements are correct?
I. We can operate on chars as if they are integers. (false)
II. Java has a simple data type boolean for logical values. (true)
Choice a
Only I is correct.
Choice b
Only II is correct.
Choice c **

Both I and II are correct.


Choice d
Both I and II are incorrect.
[3] What will be the output of the code snippet given below?
public class Main
{
public static void main ( String[ ] args )
{
double pi, r, a ;
r = 10.8 ;
pi = 3.1416 ;
a = pi * r * r ;
System.out.println ( a ) ;
}
}
Choice a ****
366.436224
Choice b
366.44
Choice c
366.43
Choice d
366.430000
[4] Which of the following statement is correct about the code snippet given
below?
public class Main
{
public static void main ( String[ ] args )
{
char ch = 'a' ;
ch = ( int ) ch ;
System.out.println ( ch ) ;
}
}
Choice a **
The code reports an error.
Choice b
The code causes an exception.
Choice c
The code gives an output as 97
Choice d
The code gives an output as a.

[5] Which of the following statements are correct? I. The Bitwise NOT operator is
called as the bitwise complement operator. (true)

II. The << operator shifts all of the bits in a value to the left a specified number
of times. (true)
Choice a
Only I is correct.
Choice b
Only II is correct.
Choice c **
Both I and II are correct.
Choice d
Both I and II are incorrect.
[6] Which of the following statements are correct? I. Nested if else statements
are not allowed in java. (false)
II. if statements are executed from top to down. (true)
Choice a
Only I is correct.
Choice b **
Only II is correct.
Choice c
Both I and II are correct.
Choice d
Both I and II are incorrect.
[7] What is the output of following block of program ?
boolean var = false;
if(var = true) {
System.out.println("TRUE");
} else {
System.out.println("FALSE");
}
Choice a **
TRUE
Choice b
FALSE
Choice c
Compilation Error
Choice d
Run-time Error
[8] Which of the following statements are correct? I. Objects of type String are
immutable. (true)
II. Once we have created a String object we can use it anywhere that a string is
allowed. (true)
Choice a
Only I is correct.
Choice b
Only II is correct.
Choice c **
Both I and II are correct.

Choice d
Both I and II are incorrect.

[9] Which of the following statements are correct?


I. References to String objects created from string literals are treated as
compile-time constants.
II. A String object knows its length and requires a special terminator. (false)
III. Any class that has a string representation should override the toString( )
method to produce the appropriate string.
Choice a
Only I and II are correct.
Choice b **
Only I and III are correct.
Choice c
Only II and III are correct.
Choice d
I, II and III are correct.
[10] What is the method available for setting the priority ?

Choice a **
setPriority()
Choice b
getPriority()
Choice c
takePriority()
Choice d
none of the above

[11]
Which of the following statement is correct?
I. An inner class is a non static nested class.
II. An inner class is a non static derived class.

Choice a **
Only I is correct.
Choice b
Only II is correct.
Choice c
Both I and II are correct.
Choice d

Both I and II are incorrect.


[12] Which two are true about a method-local inner class?
Choice a
It must be marked final.
Choice b
It can be marked abstract.

Choice c
It can be marked public.
Choice d
It can be marked static.
[13]
Which of the following statement is correct?
I. A class defined within the block of for loop is also known as inner class.
II. A class defined within the block of method can be termed as inner class.

Choice a
Only I is correct.
Choice b
Only II is correct.
Choice c **
Both I and II are correct.
Choice d
Both I and II are incorrect.

[14] Which constructs an anonymous inner class instance?


Choice a
Runnable r = new Runnable() { };
Choice b
Runnable r = new Runnable(public void run() { });
Choice c
Runnable r = new Runnable { public void run(){}};
Choice d **
System.out.println(new Runnable() {public void run() { }});

[15] What will be the output of the following program?


class Sample
{

String str ;
protected Sample( )
{
str = "hello" ;
}
Sample Fun( )
{
return this ;
}
}
class Sample1 extends Sample
{
}
class Sample2 extends Sample1
{
}
class Sample3 extends Sample2
{
}
public class Main
{
public static void main ( String[ ] args )
{
Sample S1 = new Sample3( ) ;
System.out.println ( S1.getClass( ) ) ;
}
}
Choice a
Sample
Choice b
Sample1
Choice c
Sample2
Choice d **
Sample3
[16] Which keyword is used to access the own class data members?
Choice a
my
Choice b
super
Choice c
me
Choice d **
this
[17]
Which of the following statement is correct?
I. A superclass reference variable can refer to a subclass object.

II. A subclass reference variable can refer to a superclass object.

Choice a **
Only II is correct.
Choice b
Both I and II are correct.
Choice c
Both I and II are incorrect.
Choice d
Only I is correct.

[18] If a class includes an interface but does not fully implement the methods
defined by that interface, then that class must be declared as ________.
Choice a
derived
Choice b **
abstract
Choice c
base
Choice d
final

[19] The time between Command Execution and Response is called _____

Choice a
Granularity
Choice b
Latency
Choice c
Lag time

**

Choice d
Delay time

[20]
Which of the following statement is correct?
I. A package cannot be renamed without renaming the directory in which the
classes are stored.
II. Any classes or .class files that are the part of a package must be stored in the
directory having
the same name as that of the package.

Choice a **
Both I and II are correct.
Choice b
Both I and II are incorrect.
Choice c
Only II is correct.
Choice d
Only I is correct.

[21] Which of the following statement is correct about the program given below
where package sample is defined in the file Sample.java and the class NewClass
in another file is starting point of program?
package sample ;
public class Sample
{
int n ;
public Sample( )
{
n=5;
}
static public void main ( String args[ ] )
{
System.out.print ( " Main in package" ) ;
NewClass N = new NewClass( ) ;
N.main ( args ) ;
}
}
import sample.* ;
public class NewClass
{
static Sample S = new Sample ( ) ;
public static void main ( String args[ ] )
{
System.out.print ( "Main outside the package " ) ;
}
}
Choice a
Above program
Choice b
Above program
Choice c
Above program
Choice d
Above program

will report an error on compilation.


will print the output: Main outside the package Main in package.
will report the StackOverflowError exception.
will print the output: Main in package Main outside the package.

[22] Which of the following statement is correct?

I. An exception handler is considered appropriate if the type of the exception


object thrown matches the type that can be handled by the handler.
II. When an error occurs within a method, the method creates an object and
hands it off to the runtime system.
Choice a
Both I and II are correct.
Choice b
Only I is correct.
Choice c
Both I and II are incorrect.
Choice d
Only II is correct.

[23] Which of the following statements are correct?


I. As each collection implements Iterator, the elements of any collection class
can be accessed through the methods defined by Iterator.
II. The code that cycles through a set cannot be used to cycle through a list.
Choice a **
Only I is correct.
Choice b
Only II is correct.
Choice c
Both I and II are correct.
Choice d
Both I and II are incorrect.

[24] Collections framework was designed to meet which of the following goals?
I. The framework had to be high-performance.
II. The framework had to allow different types of collections to work in a similar
manner and with a high degree of interoperability.
III. Extending and / or adapting a collection had to be easy.
Choice a
Only I and II
Choice b
Only I and III
Choice c
Only II and III
Choice d ***
I, II and III

[25] Which of the following statements are correct?


I.

Each wrapper object is immutable and stores one primitive value that is set

when the object is constructed.


II. If an Integer is passed in a place where an int is require, the compiler will
insert a call to the intValue( ) method behind the scene.
Choice a
Only I is correct.
Choice b
Only II is correct.
Choice c
Both I and II are correct.
Choice d
Both I and II are incorrect.
[26] Which of the following statements are correct?
I. Casting contexts allow the use of a boxing conversion.
II. Casting contexts do not allow the use of an unboxing conversion.
Choice a
Only I is correct.
Choice b
Only II is correct.
Choice c
Both I and II are correct.
Choice d
Both I and II are incorrect.

[27] Which of the following are the valid declarations of varargs for a method?
I. void calculate ( int... x ) { }
II. void evaluate ( int x... ) { }
Choice a
Only I
Choice b **
Only II
Choice c
Both I and II
Choice d
Neither I nor II

[28] When enabling your JAVA EE server application with SSL, which of the
following must occur?
Choice a
The certificate be issued by a third-party Certificate Authority, I.e. Verisign.
Choice b
The certificate be signed either by a Certificate Authority or self-signed.

Choice c
The Sun cryptographic provider package be installed in your JVM.
Choice d
An offline key exchange be done with the client prior to SSL communications.

[29] Which of the following statement is correct about the code snippet given
below?
class WhichOne
{
WhichOne ( Integer... size )
{
System.out.println ( "Var Args version" ) ;
}
public static void main ( String[ ] args )
{
new WhichOne ( 2, 3 ) ;
new WhichOne ( new Integer ( 2 ), new Integer ( 3 ) ) ;
}
}
Choice a **
The code reports an error
Choice b
The code causes an exception
Choice c
The code compiles successfully but does not give any output
Choice d
The code gives an output as
Var Args version
Var Args version

[30] Which of the following statement is correct?


Choice a
Accuracy of the floating point math method is measured
place.
Choice b
Accuracy of the floating point math method is measured
Choice c
Accuracy of the floating point math method is measured
Choice d
Accuracy of the floating point math method is measured

in terms of units in first

in terms of lpsu.
in terms of ulps.**
in terms of lups.

You might also like