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


Correct Option: C
Explanation:

To pass the reference of one EJB to another, you can use Dependency Injection (DI) or JNDI (Java Naming and Directory Interface). In DI, the reference to the EJB is passed through the constructor or a setter method. In JNDI, the EJB is bound to a JNDI name, and the other EJB looks up the name to get a reference to the EJB.

Option C is the correct syntax for an abstract method in a Java abstract class. The abstract keyword is used to indicate that the method has no implementation and must be overridden in a subclass. The parentheses after the method name are used to define the parameter list, and the semicolon at the end indicates the end of the method signature.

Option A is incorrect because it includes a method body, which is not allowed in an abstract method.

Option B is also incorrect because it does not include parentheses to define the parameter list, which is necessary even if the method takes no parameters.

Option D is incorrect because it includes a method body after the semicolon, which is not allowed in an abstract method.

Therefore, the correct answer is:

The Answer is: C

Find more quizzes: