Tag: architecture

Questions Related to architecture

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


Correct Option: E

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

  1. Bean Provider

  2. Application Assembler

  3. Deployer

  4. System Administrator


Correct Option: B
  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


Correct Option: A

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

  1. True

  2. False


Correct Option: B

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(){}}


Correct Option: C
Explanation:

To solve this question, the user needs to have knowledge of Java threads, Runnable interface, and the difference between extending and implementing a class/interface.

The code snippet above creates a Thread using a Runnable target. To use this code snippet, the user needs to create a class that implements the Runnable interface. The Runnable interface has only one method, which is the run() method.

Now, let's go through each option and explain why it is right or wrong:

A. public class MyRunnable extends Runnable{public void run(){}}

This option is incorrect because the Runnable interface cannot be extended. It can only be implemented.

B. public class MyRunnable extends Object{public void run(){}}

This option is incorrect because it does not implement the Runnable interface. Instead, it extends the Object class and defines a run() method, which is not the correct implementation of the run() method from the Runnable interface.

C. public class MyRunnable implements Runnable{public void run(){}}

This option is correct. It creates a class called MyRunnable that implements the Runnable interface. It defines the run() method, which is required by the Runnable interface. Therefore, this code will compile correctly.

D. public class MyRunnable implements Runnable{void run(){}}

This option is incorrect because the run() method is missing the public access modifier. The run() method must be declared as public since it is an implementation of the run() method from the Runnable interface.

Therefore, the correct answer is:

The Answer is: C