Java Senior Programmer Test Questions
Java Senior Programmer Test Questions
Select an option:
3. Suppose you want to create an instance of a new "Map" that has an order of
Iteration that is the same iteration order of an existing instance of a 'Map'.
What is the concrete implementation of the 'Map' interface that should be used for the
new instance?
a. TreeMap
b. HashMap
c. LinkedHashMap
d. The answer depends on the implementation.
4. What is true about a 'method-local inner class'?
It must be declared as final
b. It must be declared as abstract
c. It must be declared public
It must be declared as static
7. At what point is the object 'Bar' created in line 6 eligible for the garbage collector?
class Bar { }
class Test
Bar doBar()
return b; /* Line 7 */
}
newBar
finishing
a. After line 12
b. After line 14
c. After line 7 when doBar() ends
d. After line 14 when main() ends
switch (z)
{
case 4: [Link]("4 ");
case 5: [Link]("5 ");
default: assert z < 10;
}
if ( z < 10 )
assert z > 4: z++; /* Line 22 */
[Link](z);
}
}
a. Line 11
b. Line 12
c. Line 14
d. Line 22
9. What is the output of the program (When run with the -ea option)
public class Test
{
public static void main(String[] args)
{
int x = 0;
assert (x > 0) : "assertion failed"; /* Line 6 */
finished
}
}
a. finished
b. The compilation fails
c. An AssertionError is raised
An AssertionError is raised and the word finished is presented.
[Link] a = [Link](-5);
[Link] b = [Link](5.0);
c. int c = [Link](5.5F);
[Link] d = [Link](5L);
a. public int a []
b. static int [] a
c. public [] int a
d. private int a[3]
e. private int [3] a [ ]
f. public final int [] a
12. What happens if the static modifier is removed from the main() method signature?
13. On a jsp page, the attribute 'ID_User' has been created, it will be available in
any of the following scopes: pageContext, session, and request. But it is not known
to what extent will it be available exactly. Which of the following variables
can implicit ones be used to retrieve their value?
Select an option
a. Page context
b. Application
c. Config
d. Request
e. Session
@Entity
public class Address{
@Id Integer id;
...
}
Given that there is a unidirectional one-to-one assignment between the person and address, which
of the following notes should be assigned to the address field so that when
If a person entity is deleted, is the associated address also deleted?
Select an option
@OneToOne
b. @OneToOne(cascade=[Link])
c. @OneToOne(cascade=CascadeType.ORPHAN_DELETE)
d. @OneToOne(cascade=[Link])
e. @OneToOne(orphanDelete="true")
15. In the project, there is an entity called credit card that contains a
attribute cardType, which is an enumeration, as shown in the following fragment
of code.
@Entity
public class CreditCard {
...
How could the previous code be adjusted so that when a card is stored
credit, in the database column cardType contains string values ("VISA",
American Express, etc.) for the type of card?
Select an option
16. Which one fits the definition: "They are created by JSF and can be stored within
of the scope request, session or application
a. Backing Bean
b. Managed Bean
a. JdbcRowSet
b. CachedRowSet
c. WebRowSet
d. TraversalRowSet
e. JoinRowSet
c. [Link]("[Link]").newInstance();
d. [Link]("[Link]").getInstance();
20. Consider the following program and choose the best option that describes it.
behavior (assume that the connection is valid).