Java Programming and EJB Fundamentals Quiz

Test your knowledge of Java programming concepts including collections, exceptions, generics, threading, and Enterprise Java Beans (EJB) including session beans, entity beans, transaction management, and callback methods.

19 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Which of the following call back method belongs to Entity bean?

  1. void setContext()
  2. void ejbLoad()
  3. void ejbDelete()
  4. void ejbEvict()
Question 2 Multiple Choice (Single Answer)

----- cannot have local or remote interfaces?

  1. EntityBean
  2. StatefulSession Bean
  3. MessageDrivenBean
  4. StatelessSessionBean
Question 3 Multiple Choice (Single Answer)

What should be the return type of the method using @PrePassivate?

  1. Object
  2. void
  3. String
  4. Boolean
Question 4 Multiple Choice (Single Answer)

Which of the following call backs are called for the stateful session bean?

  1. construction
  2. destruction
  3. activation
  4. passivation
  5. All the above
Question 5 Multiple Choice (Single Answer)

Who is allowed to override the transaction attribute in the deployment descriptor?

  1. Bean Provider
  2. Application Assembler
  3. Deployer
  4. System Administrator
Question 6 Multiple Choice (Single Answer)

Which of the following statements are correct w.r.t. entity bean?

  1. Every entity must have a primary key
  2. It is not necessary to define primary key for an Entity
  3. @Primary annotation is used for denoting a simple primary key
  4. All the above
Question 7 True/False

Both CMT and BMT may be used with Entity and Session Beans. True or False?

  1. True
  2. False
Question 8 Multiple Choice (Single Answer)

Which of the following is valid life cycle state for a Stateless Session Bean?

  1. Does not exist
  2. Pooled State
  3. Passive
  4. None
Question 9 Multiple Choice (Single Answer)

Most EJB servers show high degree of availability. Server clusters are an example of how this is functionality is achieved. What key advantages might server clusters offer in an EJB environment?

  1. Load distribution, Load balancing capability
  2. Location transparency
  3. Caching capability
  4. 2PC (Two phase commit) capability
Question 10 Multiple Choice (Single Answer)

The following block of code creates a Thread using a Runnable target: Runnable target = new MyRunnable(); Thread myThread = new Thread(target); Which of the following classes can be used to create the target, so that the preceding code compiles correctly?

  1. public class MyRunnable extends Runnable{public void run(){}}
  2. public class MyRunnable extends Object{public void run(){}}
  3. public class MyRunnable implements Runnable{public void run(){}}
  4. public class MyRunnable implements Runnable{void run(){}}
Question 11 Multiple Choice (Single Answer)

import java.util.Scanner; public class ScannerTest { public static void main(String[] args) { Scanner scanner = new Scanner("hello 1 2.00 false"); scanner.useDelimiter(" "); String str = scanner.next(); int anInt = scanner.nextInt(); float aFloat = scanner.nextFloat(); boolean booleanValue = scanner.nextBoolean(); System.out.println(str + ":" + anInt + ":" + aFloat + ":" + booleanValue); } } what is the output?

  1. The program will output 'hello:1:2.0:false'
  2. The program will throw Input Mismatch exception at the run-time
  3. The program will output nothing.
  4. The program will ouput ':1:2.0:false'
Question 12 Multiple Choice (Single Answer)

public class Gen

  1. Compile time Error at line 1
  2. Compile time Error at line 3
  3. Compile time Error at line 4
  4. Compile time Error at line 5
  5. Run Time Error
Question 13 Multiple Choice (Single Answer)

What will be printed out if you attempt to compile and run the following code? int i=9; switch (i) { default: System.out.println("default"); case 0: System.out.println("zero"); break; case 1: System.out.println("one"); case 2: System.out.println("two"); }

  1. default
  2. default, zero
  3. error default clause not defined
  4. no output displayed
Question 14 Multiple Choice (Single Answer)

Which of the following statements are true?

  1. Methods cannot be overridden to be more private
  2. static methods cannot be overloaded
  3. private methods cannot be overloaded
  4. An overloaded method cannot throw exceptions not checked in the base class
Question 15 Multiple Choice (Single Answer)

Which of the following is not keyword or reserved word in Java?

  1. if
  2. then
  3. goto
  4. while
  5. case
Question 16 Multiple Choice (Single Answer)

What will happen if you try to compile and run the following code? public class Q { public static void main(String argv[]){ int anar[]=new int[5]; System.out.println(anar[0]); } }

  1. Error: anar is referenced before it is initialized
  2. null
  3. 0
  4. 5
Question 17 Multiple Choice (Single Answer)

What will be output if you try to compile and run the following code, but there is no file called Hello.txt in the current directory? import java.io.*; public class Mine { public static void main(String argv[]){ Mine m=new Mine(); System.out.println(m.amethod()); } public int amethod() { try { FileInputStream dis=new FileInputStream("Hello.txt"); }catch (FileNotFoundException fne) { System.out.println("No such file found"); return -1; }catch(IOException ioe) { } finally{ System.out.println("Doing finally"); } return 0; } }

  1. No such file found
  2. No such file found ,-1
  3. No such file found, Doing finally, -1
  4. 0
Question 18 Multiple Choice (Single Answer)

You need to create a class that will store unique object elements. You do not need to sort these elements but they must be unique. What interface might be most suitable to meet this need?

  1. Set
  2. List
  3. Map
  4. Vector
Question 19 Multiple Choice (Single Answer)

Which of the following statements are true?

  1. At the root of the collection hierarchy is a class called Collection
  2. The collection interface contains a method called enumerator
  3. The interator method returns an instance of the Vector class
  4. The Set interface is designed for unique elements