0% found this document useful (0 votes)
15 views7 pages

Java Senior Programmer Test Questions

The document is a Java Senior Programmer test consisting of multiple-choice questions covering various topics such as web services, Java collections, assertions, JDBC, and JSF lifecycle. Each question assesses the candidate's knowledge and understanding of Java programming concepts and best practices. The test includes questions about object-oriented principles, exception handling, and entity management in Java applications.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views7 pages

Java Senior Programmer Test Questions

The document is a Java Senior Programmer test consisting of multiple-choice questions covering various topics such as web services, Java collections, assertions, JDBC, and JSF lifecycle. Each question assesses the candidate's knowledge and understanding of Java programming concepts and best practices. The test includes questions about object-oriented principles, exception handling, and entity management in Java applications.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JAVA SENIOR PROGRAMMER TEST

1. What are the correct characteristics of a web service?


fine grain
b. Coarse Grain
c. Flexible Coupling
d. Low Coupling
e. Independent Platform
f. Dependent Platform

2. There is a company that provides stock information on its websites. Due to


to the growing demand, the financial company decides to offer its services as
web service. Most new clients have chosen to request
updates on your mobile phone through a specialized application. What is
the best solution to support this business requirement?

Select an option:

a. Build a JAX - WS web service by defining the WSDL first.


b. Build a JAX-WS web service by exposing the business logic
existing.
c. Build a JAX - RS web service by defining a WADL first.
d. Build a JAX-RS web service by exposing the business logic
existing through specified URI.

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

5. Which statement inserted on line 10 creates an instance of 'Bar'?


class Foo
{
class Bar{ }
}
class Test
{
public static void main (String [] args)
{
Foo f = new Foo();
/* Line 10: Missing statement ? */
}
}

a. [Link] b = new [Link]();


b. [Link] b = [Link]();
c. Bar b = new [Link]();
d. Bar b = [Link] Bar();

6. Which of the following allows you to destroy an object x?


a. [Link]()
b. [Link]()
c. [Link]().gc()
Only the system garbage collection can destroy objects.

7. At what point is the object 'Bar' created in line 6 eligible for the garbage collector?
class Bar { }

class Test

Bar doBar()

Bar b = new Bar(); /* Line 6 */

return b; /* Line 7 */
}

public static void main (String args[])

Test t = new Test(); /* Line 11 */

Bar newBar = [Link](); /* Line 12 */

newBar

newBar = new Bar(); /* Line 14 */

finishing

a. After line 12
b. After line 14
c. After line 7 when doBar() ends
d. After line 14 when main() ends

8. Which line in the example represents an inappropriate use of assertions:


public class Test2
{
public static int x;
public static int foo(int y)
{
return y * 2;
}
public static void main(String [] args)
{
int z = 5;
assert z > 0; /* Line 11 */
assert z > 2: foo(z); /* Line 12 */
if ( z < 7 )
assert z > 4; /* Line 14 */

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.

10. Which of the following should compile without error:

[Link] a = [Link](-5);
[Link] b = [Link](5.0);
c. int c = [Link](5.5F);
[Link] d = [Link](5L);

11. Select three options that correspond to a correct declaration of an array:

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?

The program compiles


b. The program does not compile and throws a runtime error 'NoSuchMethodError'
c. The program compiles but throws a runtime error 'NoSuchMethodError'
d. None of the above

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

14. Consider the following code


Entity
public class Person {

private Address address;


...
}

@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.

public enum CreditCardType {


VISA, MASTERCARD, DISCOVER, AMEX;
}

@Entity
public class CreditCard {
...

private CreditCardType cardType;


...
}

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

a. There is no change in the code


b. Apply @Enumerated(STRING) in CreditCardType enum.
c. Apply @Enumerated(STRING) to the cardType class attribute of the entity
Credit Card.
d. Apply @Basic on cardType the class attribute of the entity CreditCard.
e. Apply @Enum(STRING) in CreditCardType enum.

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

17. Arrange the phases of the JSF lifecycle


a. Update model values; process events
b. Process validations; process events
c. Restore view
d. Invoke application; process events
e. Render response
f. Apply request values; process events
18. Which of the following interfaces does not extend the RowSet interface?

a. JdbcRowSet
b. CachedRowSet
c. WebRowSet
d. TraversalRowSet
e. JoinRowSet

19. Which of the following statements would be needed in JDBC 3.0?

a. Connection connection = [Link] ( "jdbc : mysql : //


localhost:3306/addressBook , "root" , "password" ) )

b. Connection connection = [Link] ( " jdbc : mysql :


localhost:3306/addressBook , "root" , "password" ) )

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).

try (Statement statement = [Link]();


ResultSet resultSet = [Link]("SELECT * FROM contact")){
[Link]([Link]("id") + "\t");
+ [Link]("firstName") + "\t"
+ [Link]("lastName") + "\t"
+ [Link]("email") + "\t"
+ [Link]("phoneNo"));
}
catch (SQLException sqle) {
SQLException
}

a. This program will print the following: SQLException


b. This program will print the first contact row
c. This program will print all lines of the contact
d. This program will report compiler errors

You might also like