You are on page 1of 15

DIAGNOSTIC

Question 1.
What is the result of compiling and running the code given below?
String s= " hello 12 ";
s.trim();
System.out.println(s.length());
a. Prints 10
b. Prints 8
c. Prints 7
d. Does not compile
Question 2.
What is the result of compiling and running the code given below?
void f()
{
String s="123"; // line 1
s+="ABCD"; // line 2
s-="CD"; // line 3
System.out.println(s); // line 4
}
a. Prints "123"
b. Prints "123AB"
c. Prints "123ABCD
d. Does not compile
Question 3.
Which of the following options is the result of compiling and running the code given below?
Integer a=new Integer(12);
Byte b=new Byte((byte)12);
System.out.println(a.equals(b));
a. Compiler error
b. Prints "true"
c. Prints "false"
d. Exception at runtime

Question 4.
Which of the following options is the result of compiling and running the code given below?
class Test1
{
public static void main(String args[])
{
for(int i=0; i<10; System.out.println(i++)) ;

}
}
a.
b.
c.
d.
e.

Prints numbers from 0 to 9


Prints numbers from 0 to 10
Prints numbers from 1 to 9
Prints numbers from 1 to 10
Does not compile

Question 5.
Which of the following options is the result of compiling and running the code given below?
class MyClass
{
public static void main(String args[])
{
Box b = new Box();
b.myInt = 5;
b.doPlus(b);
System.out.println(b.myInt);
}
}
class Box
{
public int myInt;
public void doPlus(Box b1)
{
b1.myInt--;
}
}
a. Does not compile
b. Prints 0
c. Prints 5
d. Prints 4

Question 6.
Which of the given platforms have a better chance of running an applet?
a. A J2EE server environment
b. An intranet
c. The internet
d. A servlet engine
Question 7
Which of the given statements are true about swing components? Select two choices.
a. They are lightweight components.
b. They can be used in MIDlets.
c. They are faster than AWT.
d. They can be used in applets.

Question 8
Which of the given statements are true about MIDlets? Select two choices.
a. They are based on Connected Device Configuration (CDC).
b. They are based on Connected Limited Device Configuration (CLDC).
c. They are typically run in cell phones.
d. They can connect to the business tier.
Question 9
HTML clients (Choose two)
a. are more responsive than Java clients.
b. more complex to implement than Java clients.
c. offer a familiar working environment than Java clients.
d. cannot perform validations without the help of scripting languages.

Question 10
JavaScript
a. requires the Java plugin to execute.
b. is a standard J2SE scripting language.
c. supports roll over imaging.
d. runs within the browser's VM.
Question 11
Which of the given technologies is not an Enterprise Integration System (EIS) integration technology?
a. J2EE Connector Architecture
b. JDBC
c. JMS
d. JSP
Question 12
Enumerated types (enums) can be declared (Choose two)
a. outside a class.
b. inside a class.
c. inside a method.
d. inside a for loop body.
Question 13
Which of the given statements are true? (Choose two)
a. A class can extend any number of interfaces.
b. An abstract class can implement an interface.
c. An abstract class can extend another abstract class.

d. An interface can implement any number of interfaces.

Question 14
Which of the given statements are true about the program to an interface principle?
a. It allows you to use polymorphism.
b. It promotes flexibility and reusability.
c. Both A and B
d. None of these
Question 15
Which of the given statements are the benefits of encapsulation? (Choose two)
a. Better speed, since the attributes can be directly accessed without going through the operations
b. Better safety, since the attributes can be modified only through the methods
c. Better flexibility, since the attributes can be modified by any external code
d. Better reusability, since the attributes cannot be directly modified by external code
Question 16
Which of the given options determines the number of references required in the other class participating in an
association relationship?
a. Role
b. RelationCount
c. Multiplicity
d. Navigability
Question 17
A concrete class is one which (Choose two)
a. can extend an abstract class.
b. can be instantiated.
c. can have abstract methods.
d. can have only private attributes and public methods.

Question 18

Which of the given statements are true about setter methods, according to the JavaBean conventions? (Choose
two)
a. They must be public.
b. They must be private.
c. They must have a return type of void.
d. They must not take any arguments.
Question 19
Which of the given options are the primitive types? (Choose two)
a. int
b. Char
c. Integer
d. boolean
e. String
Question 20
Which of the following options are legal in the code given below? (Choose two)
class Test
{
public static void main(String args[])
{
int i=Integer.parseInt(args[0]);
}
}
a. Do nothing.
b. import java.lang.Integer;
c. package java.lang;
d. import java.lang.Number.Integer;

Question 21
Which of the given statements is true about the java.util package?
a. It contains input and output stream classes.
b. It contains classes which can be used to manipulate dates.
c. It contains AWT component classes.
d. It contains primitive wrapper classes.
Question 22
You want to set a system property named "timer" with value "on" and execute your class MyApp.class. Which
of the given commands will achieve this?
a. java -dtimer=on MyApp

b. java -Dtimer=on MyApp


c. java -d timer=on MyApp
d. java -D timer=on MyApp

Question 23
Which of the given options represents the correct order, in which package declaration, import statements, and
class definitions should appear in a source file?
a. import statements, package declaration, class definitions
b. class definitions, package declaration, import statements
c. import statements, class definitions, package declaration
d. package declaration, import statements, class definitions
e. The order does not matter.
Question 24
Which of the given options are the ways to set the classpath for the javac command? (Choose three)
a. By using the PATH environment variable
b. By using the CLASSPATH environment variable
c. Using the -classpath option with the javac command
d. Using the -path option with the javac command
e. Using the -cp option with the javac command
Question 25.
Enumerated types in Java are subclasses of
a. java.lang.Enumeration.
b. java.lang.Enum.
c. java.lang.EnumClass.
d. java.lang.EnumType.
Question 26
Regarding the given UML diagram below, which of the following code fragment shows the relationship
between classes P and Q?

a. class P
{
Q[] q;
}
class Q{}
b. class P{}
class Q
{

P[] p;
}
c. class P
{
Q q;
}
class Q
{
P[] p;
}
d. class P
{
Q[] q;
}
class Q
{
P p;
}
Question 27.
Which of the given code fragments will not compile?(Choose two)
a. byte a=128;
b. byte b=100;
b*=1;
c. byte b=1;
b=b+1;
d. int i=128;
byte a=(byte)i;
Question 28.
Regarding the code given below, which of the following options will compile correctly?
enum Taste{ SOUR, SWEET, BITTER, SPICY; }
a. Taste t=new Taste(SOUR);
b. Taste t=1;
c. Taste t=Taste.SOUR;
d. Taste t=new Taste(Taste.SOUR);
e. Taste t= "SOUR";
Question 29.
Which of the following options is the result of compiling and running the code given below?
class FruitSeller
{
enum Fruit { ORANGE("orange"), APPLE("red"); }
public static void main(String[] args)
{
System.out.println(Fruit.ORANGE);
}
}

a.
b.
c.
d.
e.

Compiler error
Exception at runtime
Prints orange
Prints ORANGE
Prints Fruit.ORANGE

Question 30.
Which of the given code fragments correctly create an array? (Choose two)
a. int [] x = {1,2,0};
b. int x [] = (0,1,2);
c. int array [] = new int [3];
d. int x [] = new int(3);
Question 31.
Which of the given code fragments will compile without errors? (Choose two)
a. int i=true;
b. float b=0;
c. double d=-1;
d. float s=1.2;
Question 32
Which of the given statements are true?(Choose two)
a. Abstract classes and interfaces cannot have constructors.
b. Constructors can be private or protected.
c. Constructors can be overridden by subclasses.
d. You can throw exceptions from constructors.
Question 33
Regarding the code given below:
public interface MyInter
{
void myMethod();
}
The concrete class which implements MyInter
a. may or may not define myMethod().
b. must define myMethod() with default access.
c. must define myMethod() with public access.
d. may define myMethod as abstract.
Question 34
Which of the following options is the result of the code given below?
class Test
{
private int i;
}

class NewTest extends Test


{
i=10;
void f()
{
System.out.println(i);
}
public static void main(String args[])
{
NewTest n=new NewTest();
n.f();
}
}
a. Prints 0
b. Prints 10
c. Compiler error because the variable i is not initialized
d. None of these
Question 35
Which of the given options are true about RMI? (Choose two)
a. Allows communication with non-Java objects also
b. Involves the use of a stub on the client side
c. Faster than socket communication
d. Simpler to use than sockets
Question 36
SQL (Structured Query Language) (Choose two)
a. is an object oriented language.
b. can be used only in Java applications.
c. can be used in non-Java applications.
d. used to access data from relational databases.
Question 37
All existing J2SE applications can run
a. only in a J2SE environment.
b. in J2SE and J2EE environments only.
c. in J2SE and J2ME environments only.
d. in J2SE, J2EE and J2ME environments.
Question 38
Which of the given technologies will you need to use to develop an application that will run on cell phones?
a. J2ME only
b. J2SE only
c. Both J2ME and J2SE
d. None of these

Question 39.
Which of the given APIs is used to connect to an RDBMS from a Java application?
a. JNI
b. JNDI
c. JDBC
d. RMI
|
Question 40.
A servlet (Choose two)
a. executes within the browser of the client.
b. can be plugged into a Java-enabled web server.
c. does not require a VM to execute.
d. can work as an EJB client.
Question 41.
Message-driven beans (Choose two)
a. can be accessed directly by clients.
b. are asynchronous message consumers.
c. can call the methods of other enterprise beans.
d. expose home and component interfaces.
Question 42.
Which of the given statements is true about Java Message Service (JMS)?
a. The JMS API is defined in the javax.jms package.
b. JMS includes interface for lookup and directory services.
c. JMS allows tightly coupled distributed communication.
d. All of the above

Question 43.
Which of the given components are parts of business tier?(Choose two)
a. Stateful Session Bean
b. Entity Bean
c. Servlet
d. JSP
e. JavaBeans
Question 44.

Which of the following statements are true regarding the UML diagram? (Choose two)

a. The diagram is invalid.


b. The diagram is valid.
c. The diagram would also be valid if the word <<interface>> is removed.
d. The diagram would also be valid if the word <<interface>> is replaced by <<class>>.
Question 45.
A class that implements an interface is connected to that interface using
a. a solid line with a triangle at the interface end.
b. a dashed line with a triangle at the class end.
c. a dashed line with a triangle at the interface end.
d. a solid line with a triangle at the class end.

Question 46.

Which of the following statements is true about the UML diagram given below?

a. The diagram shows C and B extending V.


b. The diagram shows C and B implementing V.
c. The diagram uses invalid UML notation.
d. The diagram shows a composition relation.
Question 47.
Regarding the diagram given below, which of the given members of
SC are accessible from C?

a.
b.
c.
d.

myVar
setVar
getVar
None of these

Question 48.
Regarding the class definitions given below, which of the given UML diagrams correctly describes the
relationship between classes?

public class Person


{
private Company employer;
}
public class Company{}
a.
b.
c.
d.

A
B
C
D

Question 49.
You want to show a composition relationship where B is part-of A. Which of the given UML diagrams shows
the relationship correctly?

a.
b.
c.
d.

Question 50.

A
B
C
D

Regarding the UML diagram given below, which of the following statements are true? (Choose two)

a.
b.
c.
d.

This UML diagram is valid.


This UML diagram is invalid.
This UML diagram would be valid if the 2 triangles are fused into a single triangle.
This UML diagram would be valid if Shape is represented as an interface.

Question 51.
Which of the following statement is true about the UML diagram given below?

a.
b.
c.
d.

This is a valid object diagram.


This is a valid class diagram.
This is an invalid UML diagram.
This is a valid UML diagram, but not a class diagram or an object diagram.

You might also like