Technical Papers Java Questions: IFlex Java 2004
Doorsteptutor material for competitive exams is prepared by world's top subject experts: get questions, notes, tests, video lectures and more- for all subjects of your exam.
COMPANY NAME: i-Flex
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.
PATTERN:
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.
PAPER:
In the init (ServletConfig) method of Servlet life cycle, what method can be used to access the ServletConfig object?
- getServletInfo ()
- getInitParameters ()
- 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?
- session, request
- exception, request
- exception, config
- session, exception
ANS: I think answer is (d)
ejbCreate () method of CMP bean returns
- null
- Primary Key class
- Home Object
- 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?
- abstract double area () {}
- abstract double area ()
- abstract double area ()
- 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.
- The Session is not valid in the new Window
- The Session is valid in the new Window
ANS: I think the answer is (b)
Which of the following JSP expressions are valid?
- <% = “Sorry” + “for the” + “break” %>
- <% = “Sorry” + “for the” + “break” %>
- <% = “Sorry” %>
- <% = “Sorry” %>
ANS:
A class can be converted to a thread by implementing the interface ________
- Thread
- 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” ) ;}
- TRUE
- FALSE
- Compilation Error
- 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?
- Thread Management
- Transient Fields
- Listening on a Socket
ANS:
What happens if Database Updation code is written in ejbPassivate () method and if this method is called?
- Exception is thrown
- Successfully executes the Database Updation code
- Compilation error occurs indicating that Database Updation code should not be written in ejbPassivate ()
- ejbStore () method is called
ANS:
A Vector is declared as follows. What happens if the code tried to add 6th element to this Vector
new vector (5,10)
- The element will be successfully added
- ArrayIndexOutOfBounds Exception
- The Vector allocates space to accommodate up to 15 elements
ANS: (a) and (c)
EXPLANATION: The 1st argument in the constructor is the initial size of Vector and the 2nd argument in the constructor is the growth in size (for each allocation)
This Vector is created with 5 elements and when an extra element (6th one) is tried to be added, the vector grows in size by 10.
Which is the data structure used to store sorted map elements?
- HashSet
- Hashmap
- Map
- TreeMap
ANS: I think the answer is (d)
SessionListerner defines following methods
- sessionCreated, sessionReplaced
- sessionCreated, sessionDestroyed
- sessionDestroyed, sessionReplaced
ANS:
Which of the following is true?
- Stateless session beans doesn՚t preserve any state across method calls
- Stateful session beans can be accesses by multiple users at the same time
ANS: (a)
Stateful Session beans contain
- Home Interface
- Remote Interface
- Bean Class
- All
ANS: (d)
What is the Life Cycle of Session bean?
Stateless session bean is instantiated by
- newInstance ()
- create ()
ANS:
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?
- Only the variable number
- Only the HttpServletRequest object req
- Both the variable number & the HttpServletRequest object req
If you are trying to call an EJB that is timed out, what will happen?
- Exception
- It gets executed
A method is defined in a class as:
void processUser (int i) {}
If this method is overriden in a sub class, ________
- the new method should return int
- the new method can return any type of values
- the argument list of new method should exactly match that of overriden method
- 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.
- The Name of person is: Chetana
- The Name of person is:
- The Name of person is: Null
- None
ANS: (a)
Without the use of Cartesian product, how many joining conditions are required to join 4 tables?
- 1
- 2
- 3
- 4
ANS:
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” ) ;}
- No output
- 3 and 5
- 1,3 and 5
- 3
ANS: (b)