OCPJBCD Mock Exam – 4

1 . Which of the following statements are true about the Entity class?

  1. Entity class must not have no-arg constructor
  2. Entity class must be declared as top level class
  3. Interface cannot be Entity
  4. Enum can be declared as Entity

2 . Which of the following are correct?

  1. @EntityBean
    public class Employees{
    ...
    }
  2. @Entity
    public class Employees{
    ...
    }
  3. @EntityBean
    public class Employees implements Serializable{
    ...
    }
  4. class Employees{
    	@Entity
    	private class Address{
    		...
    	}
    	...
    }

Choose the one below:

  1. 1
  2. 2
  3. 3
  4. 4

3 . If you want to send an entity object as the pass by value through a remote interface, which of the following statements are valid?

  1. @Entity
    public class Employees implements SessionSynchronization{
    ...
    }
  2. @Entity
    public class Employees implements Serializable{
    ...
    }
  3. public class Employees implements Serializable{
    ...
    }
  4. @entity
    public class Employees implements Serializable{
    ...
    }

Choose the one below:

  1. 1
  2. 2
  3. 3
  4. 4

4 . Which of the following statements are correct?

  1. @Entity
    final public class Employees{
    ...
    }
  2. @Entity
    abstract public class Employees{
    ...
    }
  3. @Entity
    public class Employees extends Parent{
    ...
    }

Choose the one below:

  1. 1
  2. 2
  3. 3

5 . Which of the following statements are correct?

  1. @Entity
    public class Company{
    ...
    }
    public class Employee extends Company{
    ...
    }
  2. @Entity
    public class Company{
    ...
    }
    @Entity
    public class Employee extends Company{
    ...
    }
  3. public class Company{
    ...
    }
    @Entity
    public class Employee extends Company{
    ...
    }
  4. All the above

Choose the one below:

  1. 1
  2. 2
  3. 3
  4. 4

6 . Which of the following statements are correct?

  1. Entities supports inheritance
  2. Abstract class and concrete classes can be entities
  3. Intance variables of an entity class can be public
  4. Instance variables of an entity class must be private,protected or package visibility

7 . Which of the following statements are correct?

  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

8 . Select the valid primary key types?

  1. long
  2. Integer
  3. java.lang.String
  4. java.sql.Date
  5. java.util.Date
  6. All the above

9 . Which of the following are true about composite primary keys?

  1. The primary key class must be Serilizable
  2. The application must not change the value of the primary key
  3. Properties of primary key class must be public or protected
  4. Primary key class must be public
  5. All the above

10 . Which of the following are not true about composite primary keys?

  1. The primary key class must define equals and hasfCode methods
  2. The primary key class may not define equals and hashCode methods
  3. Must have public no-arg constructor
  4. May not have public no-arg constructor

Answers

1 : 2 & 4 is correct.

2 : 2 & 3 is correct.
Explanation:
Must be annotated with @Entity.
Entity class must be a top level class.

3 : 2 is correct.
Explanation:
Entity class must implement the Serializable interface when the entity object is passed by value.
@Entity is used for annotating the Entity class.

4 : 2 & 3 is correct.
Explanation:
Entity class extends another entity or non-entity class.
Abstract classes can be entity.
Final classes cannot be entity.

5 : 4 is correct.

6 : 1,2 & 4 is correct.

7 : 1 is correct.

8 : 6 is correct.

9 : 5 is correct.

10 : 2 & 4 is correct.

Comments

comments

About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.

Speak Your Mind

*