Sun Java Questions: iFlex Java 2004Tab.Amp

Examrace Placement Series prepares you for the toughest placement exams to top companies.


DATE OF TEST: 20 Feb 2004

PLACE OF TEST: i-Flex, Nungambakkam, Chennai

MODE: Off-Campus

DURATION: 35 Minutes

This is i-flex paper for 2 + years experienced in JAVA and J2EE

NOTE: I have written whatever I remember. Some questions may not be complete or options may be a bit different than the ones given here. Also I have written whatever answers I know. Don't take them as final, as some of them may be wrong.


35 multiple choice Questions in 35 minutes

Questions are mainly from CORE JAVA, JSP, SERVLETS, EJB and few DATABASE related ones.

IMPORTANT: Multiple answers are possible for few questions. You need to mark all the answers to get the marks for those questions.


In the init (ServletConfig) method of Servlet life cycle, what method can be used to access the ServletConfig object?

  1. getServletInfo ()

  2. getInitParameters ()

  3. getServletConfig ()

ANS: (c)

The Page directive in JSP is defined as follows: < %@ page language = “Java” session = “false” isErrorPage = “false” % >

Then which of the implicit objects won't be available?

  1. session, request

  2. exception, request

  3. exception, config

  4. session, exception

ANS: I think answer is (d)

ejbCreate () method of CMP bean returns

  1. null

  2. Primary Key class

  3. Home Object

  4. Remote Object

ANS: (a)

Explanation: EjbCreate () method of BMP bean returns the Primary Key, where as ejbCreate () method of CMP bean returns null.

How can a EJB pass it's reference to another EJB?

Which of the following is correct syntax for an Abstract class?

  1. abstract double area () { }

  2. abstract double area ()

  3. abstract double area ()

  4. abstract double area (); { }

ANS: (c)

A JSP page is opened in a particular Session. A button is present in that JSP page onclick of which a new Window gets opened.

  1. The Session is not valid in the new Window

  2. The Session is valid in the new Window

ANS: I think the answer is (b)

Which of the following JSP expressions are valid?

  1. <% = “Sorry” + “for the” + “break” %>

  2. <% = “Sorry” + “for the” + “break” %>

  3. <% = “Sorry” %>

  4. <% = “Sorry” %>


A class can be converted to a thread by implementing the interface __________

  1. Thread

  2. Runnable

ANS: (b)

What is the output of following block of program?

boolean var = false.

if (var = true) { System. Out. Println ( “TRUE” ); } else { System. Out. Println ( “FALSE” ); }

  1. TRUE

  2. FALSE

  3. Compilation Error

  4. Run-time Error

ANS: (a)

EXPLANATION: The code compiles and runs fine and the ‘if’ test succeeds because ‘var’ is set to ‘true’ (rather than tested for ‘true’ ) in the ‘if’ argument.

Which is not allowed in EJB programming?

  1. Thread Management

  2. Transient Fields

  3. Listening on a Socket


What happens if Database Updation code is written in ejbPassivate () method and if this method is called?

  1. Exception is thrown

  2. Successfully executes the Database Updation code

  3. Compilation error occurs indicating that Database Updation code should not be written in ejbPassivate ()

  4. ejbStore () method is called


A Vector is declared as follows. What happens if the code tried to add 6 th element to this Vector

new vector (5, 10)

  1. The element will be successfully added

  2. ArrayIndexOutOfBounds Exception

  3. The Vector allocates space to accommodate up to 15 elements

ANS: (a) and (c)

EXPLANATION: The 1 st argument in the constructor is the initial size of Vector and the 2 nd argument in the constructor is the growth in size (for each allocation)

This Vector is created with 5 elements and when an extra element (6 th one) is tried to be added, the vector grows in size by 10.

Which is the data structure used to store sorted map elements?

  1. HashSet

  2. Hashmap

  3. Map

  4. TreeMap

ANS: I think the answer is (d)

SessionListerner defines following methods

  1. sessionCreated, sessionReplaced

  2. sessionCreated, sessionDestroyed

  3. sessionDestroyed, sessionReplaced


Which of the following is true?

  1. Stateless session beans doesn't preserve any state across method calls

  2. Stateful session beans can be accesses by multiple users at the same time

ANS: (a)

Stateful Session beans contain

  1. Home Interface

  2. Remote Interface

  3. Bean Class

  4. All

ANS: (d)

What is the Life Cycle of Session bean?

Stateless session bean is instantiated by

  1. newInstance ()

  2. create ()


A servlet implements Single Thread model

public class BasicServlet extends HttpServlet implements SingleThreadModel { int number = 0; public void service (HttpServletRequest req, HttpServletResponse res) { } }

Which is thread safe?

  1. Only the variable number

  2. Only the HttpServletRequest object req

  3. Both the variable number & the HttpServletRequest object req

If you are trying to call an EJB that is timed out, what will happen?

  1. Exception

  2. It gets executed

A method is defined in a class as:

void processUser (int i) { }

If this method is overriden in a sub class, _____

  1. the new method should return int

  2. the new method can return any type of values

  3. the argument list of new method should exactly match that of overriden method

  4. the return type of new method should exactly match that of overriden method

ANS: (c) & (d)

In a JSP page, a statement is declared as follows:

<%! String strTemp = request. GetParameter ( “Name” ); %>

And below that, an _expression appears as:

<% System. Out. Println ( “The Name of person is:” + strTemp); %>

What is the output of this _expression.

  1. The Name of person is: Chetana

  2. The Name of person is:

  3. The Name of person is: Null

  4. None

ANS: (a)

Without the use of Cartesian product, how many joining conditions are required to join 4 tables?

  1. 1

  2. 2

  3. 3

  4. 4


What is the output of following piece of code?

int x = 2.

switch (x) { case 1: System. Out. Println ( “1” ); case 2: Case 3: System. Out. Println ( “3” ); case 4: Case 5: System. Out. Println ( “5” ); }

  1. No output

  2. 3 and 5

  3. 1, 3 and 5

  4. 3

ANS: (b)