Professional Documents
Culture Documents
(1)
1. Which of the following statements are correct? [Select all correct answers]
2. Which of the following are not Java keywords? [Select all correct answers]
1. extern
2. long
3. elsif
4. case
3. Its not just Stateless Session Beans that are pooled, Entity Beans are as well.
True/False?
1. True
2. False
4. Which of the following methods are invoked on a stateless session bean when it is in
the method ready pool?
1. ejbCreate
2. ejbActivate
3. ejbPassivate
4. setSessionContext
5. unsetSessionContext
6. business methods
7. ejbRemove
6. A class design requires that a particular member variable must be accessible for direct
access by any subclasses of this class, otherwise not by classes which are not members of
the same package. What should be done to achieve this?
A) True.
B) False.
12. Which of the following statements regarding a web application deployed on J2EE
server are true? Select three choices.
1. The configuration information is maintained in an XML file called web
application deployment descriptor.
2. The web components are packaged in a file with war as an extension.
3. The web components are packaged in a file with jar as an extension.
4. The web application packages can be created using the war utility.
5. The web application packages can be created using jar utility.
13. You have been given a design document for a veterinary registration system for
implementation in Java technology. It states:
"A pet has an owner, a registration date, and a vaccination-due date. A cat is a pet that
has a flag indicating if it has been neutered, and a textual description of its markings."
Given that the Pet class has already been defined, which of the following fields would be
appropriate for inclusion in the Cat class as members?
A. Pet thePet;
B. Date registered;
C. Date vaccinationDue;
D. Cat theCat;
E. boolean neutered;
F. String markings;
What output results when the main method of the class Sub is run?
A. Value is 5
Value is 6
B. This value is 5
This value is 6
C. Value is 5
This value is 6
D. This value is 5
Value is 6
E. I was passed 5
I was passed 6
Answers (1)
1. Answers 1 and 2 are correct. 1 is correct because array indexes in Java always start at
0. Answer 2 is also correct. An instance variable is a field declared within a class
declaration without the static keyword. When an instance of the class is created, any
declared instance variables are also created and initialized to a default value.
2. Answers 1 and 3 are correct because extern and elsif are not Java keywords.
Answers 2 and 4 are incorrect because they are valid Java keywords.
5. Answer: C. Strings are immutable. So str.concat("to Java!") will not append anything
to str. In fact it will create another string "Welcome to Java!" and leaves it.
9. Answer: D
11. Answers 1, 2 and 5 are correct. 3 and 4 are invalid because the array size may not be
given when the array is declared.
13. Answer: E and F are correct. The Cat class is a subclass of the Pet class, and as such
should extend Pet, rather than containing an instance of Pet. B and C should be members
of the Pet class and as such are inherited into the Cat class; therefore, they should not be
declared in the Cat class. D would declare a reference to an instance of the Cat class,
which is not generally appropriate inside the Cat class itself (unless, perhaps, you were
asked to give the Cat a member that refers to its mother). Finally, the neutered flag and
markings descriptions, E and F, are the items called for by the specification; these are
correct items.
14. Answer: C is correct. The first message is produced by the Base class when
b1.method(5) is called and is therefore Value is 5. Despite variable b2 being declared as
being of the Base class, the behavior that results when method() is invoked upon it is the
behavior associated with class of the actual object, not with the type of the variable. Since
the object is of class Sub, not of class Base, the second message is generated by line 3 of
class Sub: This value is 6.
Additional verbal questions: