site stats

SCJA Mini Mock Exam

Q1)
Which of the following statements are true?
  • a) Encapsulation and Information hiding are used interchangeably.
  • b) Encapsulation is a language feature.
  • c) Information hiding is a design principle.
  • d) Java can have encapsulated data that is not hidden.
  • e) All of the above
Answer to Q1

Q2)
Examine the following UML notation and identify the relationship between class A and class B:

  • a) Dependency
  • b) Association
  • c) Aggregation
  • d) Composition
Answer to Q2

Q3)
Examine the following UML notation and determine its Java code implementation:

  • a)
    
    class B {}
    public class A {
    	public void method1 (B b) {
    		//Code
    	}
    }
    
  • b)
    
    class B {}
    public class A {
    	private B b;
    	// code
    }
    
  • c)
    
    class B {}
    public class A extends B {
    	//code
    }
    
  • d)
    
    interface B {}
    public class A implements B {
    	//code
    }
    
Answer to Q3

Q4)
Which of the following statement(s) are not true about JavaBeans?
  • a) JavaBeans implements java.io.serializable interface.
  • b) JavaBeans provides no argument constructor.
  • c) JavaBeans provides getter and setter method for accessing its properties.
  • d) JavaBeans class can contain public instance variable.
  • e) None of the above
Answer to Q4

Q5)
How many class variables does the following class has?
public class MyClass{
	public static int x = 1;
	public char y = 'S';
}

  • a) 0
  • b) 1
  • c) 2
Answer to Q5

Q6)
Object created using new is placed on
  • a) Stack
  • b) Queue
  • c) Heap
  • d) None of the above.
Answer to Q6

Q7)
What is the output of the following class:
public class  MyClass{
	public static void main(String[] args) {
		String strMsg = "Welcome";
		strMsg += " to SCJA";
		strMsg.concat(" Certificate");
		System.out.println(strMsg);
	}
}

  • a) Welcome
  • b) Welcome to SCJA
  • c) Welcome to SCJA Certificate
Answer to Q7

Q8)
Entity beans are used to
  • a) model processes, services and session objects
  • b) process asynchronous messages.
  • c) model persistent data objects
  • d) none of the above.
Answer to Q8

Q9)
At Client, remote object proxy is termed as
  • a) Stub
  • b) RemoteRef
  • c) Skeleton
  • d) None of the above
Answer to Q9

In J2EE architecture, Enterprise Beans belongs to
  • a) Client tier
  • b) Web tier
  • c) Business tier
  • d) EIS tier
Answer to Q10

ANSWERS

Q1)
Answer : e
Explanation : All the options (a, b, c, d) are correct.
Encapsulation and Information Hiding are used interchangeably.
Encapsulation is a language facility whereas data hiding is a design principle. Encapsulation means bundling of data and methods that operate on them within an object. Ideally this should imply that data related to an object is hidden and invisible outside the object. However, in Java we can define encapsulated data that is not hidden, by defining the instance variables of a class as public members.
For example, in the following class definition, data related to class Chair (materialUsed) is encapsulated, but not hidden:
public class Chair {
	public String materialUsed;
}

Answer : b
Explanation :
  • a) Dependency is shown through dotted lines with arrow head.
  • c) Aggregation is represented through empty diamond at composed class.
  • d) Composition is represented through solid diamond at composed class.
Return to Q2

Answer : c
Explanation : Clear triangle arrowhead pointing at super class from sub class is used to represent Generalization.
  • a) Class A defines method 'method1(B b)', which accepts an instance of Class B as a method parameter. Class A is dependent on class B and hence this represents a dependency relationship.
  • b) Class A defines an instance of Class B, but B is not aware of Class A. Hence this represents association relationship.
  • d) Class A implements class B, hence this represents a realization relationship.
Return to Q3

Answer : a, d
Explanation : Options b, c are true statements, as Java beans are java classes with coding conventions.
Java bean classes can not define public instance variables.
Properties of a Java bean are accessed through its corresponding 'get' and 'set' public accessor methods. For e.g., if a Java Bean defines public getName() and setName() methods, it defines a property 'name'. If a Java bean defines just the 'getter' method (getName), but no corresponding 'setter' method (setName), it defines a read-only property 'name'.
It is important to note that the name of the property of a Java bean is not related to the name of the instance variable that is actually used to store the property value.
All beans must support either Serialization or Externalization.
Java bean must define a zero argument constructor. We can do this by explicitly defining a zero argument constructor, or by not defining any constructor. If a class does not defines any constructor, Java defines a no-argument constructor for it.

Answer : b
Explanation : Class has one class variable "x" and one local variable "y".

Answer : c
Explanation : When an object is created using the 'new' keyword, it is placed on the Heap. Heap and Stack are two different data structures that are imaginary places in memory. All objects values are stored on heap, if they are created using "new" and their existence is managed by Garbage Collector. Variables, if created locally are stored on Stack and their lifetime depends on scope of the method.

Answer: b
Explanation : String is immutable. The above code will print "Welcome to SCJA".
+= will assign string concatenation result to strMsg, i.e., strMsg = strMsg + "to SCJA". While strMsg.concat("Certificate") creates a new string which is not assigned to any string variable.
To print "Welcome to SCJA Certificate", strMsg.concat("certificate") should be assigned to a string variable, e.g., strMsg = strMsg.concat("Certificate");

Answer : c
Explanation : Entity beans are persistent objects that are stored on permanent storage.
  • a) Session beans represents business processes, services and session objects
  • b) Message driven beans are used to process asynchronous messages.
Return to Q8

Answers : a
Explanation : In Client Server architecture remote object proxy is called Stub.
  • b) RemoteRef : The Remote reference layer provides RemoteRef object that represents link to remote service implementation object.
  • c) Skeleton is a helper class that is used how to communicate with stub across RMI link.

Answer : c
Explanation : Business code is handled by Enterprise beans running in business tier. It receives data from client programs, processes it and sends it to EIS (Enterprise Information System) for repository. Similarly EJB retrieves data from repository, processes it and sends it to the client.









Feedback


Please help us to improve this quiz by submitting your feedback.

Name
Email Address
Rate the above SCJA Quiz Very difficult
difficult
OK
Easy
Very Easy
Comments & Suggestions
 
(Please enter your email address, if you want to hear from us)