Black Friday Special Sale Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: buysanta

Exact2Pass Menu

Question # 4

Given the code fragment:

What is the result?

A.

Java EEJava EESE

B.

Java EESE

C.

The program prints either:Java EEJava SEorJava SEJava EE

D.

Java EEJava SE

Full Access
Question # 5

Given:

What is the result?

A.

Bar HelloFoo Hello

B.

Bar HelloBaz Hello

C.

Baz Hello

D.

A compilation error occurs in the Daze class.

Full Access
Question # 6

Given that course.txt is accessible and contains:

Course : : Java

and given the code fragment:

public static void main (String[ ] args) {

int i;

char c;

try (FileInputStream fis = new FileInputStream (“course.txt”);

InputStreamReader isr = new InputStreamReader(fis);) {

while (!isr.close()) { //line n1

isr.skip(2);

i = isr.read ();

c = (char) i;

System.out.print(c);

}

} catch (Exception e) {

e.printStackTrace();

}

}

What is the result?

A.

ur :: va

B.

ueJa

C.

The program prints nothing.

D.

A compilation error occurs at line n1.

Full Access
Question # 7

Which code fragment is required to load a JDBC 3.0 driver?

A.

Connection con = Connection.getDriver(“jdbc:xyzdata://localhost:3306/EmployeeDB”);

B.

Class.forName(“org.xyzdata.jdbc.NetworkDriver”);

C.

Connection con = DriverManager.getConnection(“jdbc:xyzdata://localhost:3306/EmployeeDB”);

D.

DriverManager.loadDriver (“org.xyzdata.jdbc.NetworkDriver”);

Full Access
Question # 8

Given the code fragment:

What is the result?

A.

[X][X, X][X, X, X][X, X, X, X]

B.

[X, X]

C.

[X][X, X][X, X, X]

D.

[X, X][X, X, X, X]

Full Access
Question # 9

Given the code fragment:

Stream files = Files.walk(Paths.get(System.getProperty(“user.home”)));

files.forEach (fName -> {//line n1

try {

Path aPath = fName.toAbsolutePath();//line n2

System.out.println(fName + “:”

+ Files.readAttributes(aPath, Basic.File.Attributes.class).creationTime

());

} catch (IOException ex) {

ex.printStackTrace();

});

What is the result?

A.

All files and directories under the home directory are listed along with their attributes.

B.

A compilation error occurs at line n1.

C.

The files in the home directory are listed along with their attributes.

D.

A compilation error occurs at line n2.

Full Access
Question # 10

Given that course.txt is accessible and contains:

Course : : Java

and given the code fragment:

public static void main (String[ ] args) {

int i;

char c;

try (FileInputStream fis = new FileInputStream (“course.txt”);

InputStreamReader isr = new InputStreamReader(fis);) {

while (isr.ready()) { //line n1

isr.skip(2);

i = isr.read ();

c = (char) i;

System.out.print(c);

}

} catch (Exception e) {

e.printStackTrace();

}

}

What is the result?

A.

ur :: va

B.

ueJa

C.

The program prints nothing.

D.

A compilation error occurs at line n1.

Full Access
Question # 11

Given records from the Player table:

and given the code fragment:

try {

Connection conn = DriverManager.getConnection(URL, username, password);

Statement st= conn.createStatement(

ResultSet.TYPE_SCROLL_SENSITIVE,

ResultSet.CONCUR_UPDATABLE);

st.execute (“SELECT * FROM Player”);

st.setMaxRows(2);

ResultSet rs = st.getResultSet();

rs.absolute(3);

while (rs.next ()) {

System.out.println(rs.getInt(1) + “ “ + rs.getString(2));

}

} catch (SQLException ex) {

System.out.print(“SQLException is thrown.”);

}

Assume that:

The required database driver is configured in the classpath.

The appropriate database is accessible with URL, username, and password.

The SQL query is valid.

What is the result?

A.

2 Jack3 Sam

B.

The program prints nothing.

C.

3 Sam

D.

SQLException is thrown.

Full Access
Question # 12

Given the code fragment:

public class Foo {

public static void main (String [ ] args) {

Map unsortMap = new HashMap< > ( );

unsortMap.put (10, “z”);

unsortMap.put (5, “b”);

unsortMap.put (1, “d”);

unsortMap.put (7, “e”);

unsortMap.put (50, “j”);

Map treeMap = new TreeMap (new

Comparator ( ) {

@Override public int compare (Integer o1, Integer o2) {return o2.compareTo

(o2); } } );

treeMap.putAll (unsortMap);

for (Map.Entry entry : treeMap.entrySet () ) {

System.out.print (entry.getValue () + “ “);

}

}

}

What is the result?

A.

A compilation error occurs.

B.

d b e z j

C.

j z e b d

D.

z b d e j

Full Access
Question # 13

Given the code fragment:

class CallerThread implements Callable {

String str;

public CallerThread(String s) {this.str=s;}

public String call() throws Exception {

return str.concat(“Call”);

}

}

and

public static void main (String[] args) throws InterruptedException, ExecutionException

{

ExecutorService es = Executors.newFixedThreadPool(4); //line n1

Future f1 = es.submit (newCallerThread(“Call”));

String str = f1.get().toString();

System.out.println(str);

}

Which statement is true?

A.

The program prints Call Call and terminates.

B.

The program prints Call Call and does not terminate.

C.

A compilation error occurs at line n1.

D.

An ExecutionException is thrown at run time.

Full Access
Question # 14

You have been asked to create a ResourceBundle which uses a properties file to localize an application.

Which code example specifies valid keys of menu1 and menu2 with values of File Menu and View Menu?

A.

File MenuView Menu

B.

menu1File Menumenu2View Menu

C.

menu1, File Menu, menu2, View Menu

D.

menu1 = File Menumenu2 = View Menu

Full Access
Question # 15

Given:

class Bird {

public void fly () { System.out.print(“Can fly”); }

}

class Penguin extends Bird {

public void fly () { System.out.print(“Cannot fly”); }

}

and the code fragment:

class Birdie {

public static void main (String [ ] args) {

fly( ( ) -> new Bird ( ));

fly (Penguin : : new);

}

/* line n1 */

}

Which code fragment, when inserted at line n1, enables the Birdie class to compile?

A.

static void fly (Consumer bird) {bird :: fly ();}

B.

static void fly (Consumer bird) {bird.accept( ) fly ();}

C.

static void fly (Supplier bird) {bird.get( ) fly ();}

D.

static void fly (Supplier bird) {LOST

Full Access
Question # 16

Given:

What is the result?

A.

Hi Interface-2

B.

A compilation error occurs.

C.

Hi Interface-1

D.

Hi MyClass

Full Access
Question # 17

Given the code fragment:

and the information:

  • The required database driver is configured in the classpath.
  • The appropriate database is accessible with the dbURL, username, and passWord exists.

What is the result?

A.

A ClassNotFoundException is thrown at runtime.

B.

The program prints nothing.

C.

The program prints Connection Established.

D.

A SQLException is thrown at runtime.

Full Access
Question # 18

Given the code fragment:

Which is the valid definition of the Course enum?

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Full Access
Question # 19

Given:

class Student {

String course, name, city;

public Student (String name, String course, String city) {

this.course = course; this.name = name; this.city = city;

}

public String toString() {

return course + “:” + name + “:” + city;

}

public String getCourse() {return course;}

public String getName() {return name;}

public String getCity() {return city;}

and the code fragment:

List stds = Arrays.asList(

new Student (“Jessy”, “Java ME”, “Chicago”),

new Student (“Helen”, “Java EE”, “Houston”),

new Student (“Mark”, “Java ME”, “Chicago”));

stds.stream()

.collect(Collectors.groupingBy(Student::getCourse))

.forEach(src, res) -> System.out.println(res));

What is the result?

A.

A compilation error occurs.

B.

Java EEJava ME

C.

[Java EE: Helen:Houston][Java ME: Jessy:Chicago, Java ME: Mark:Chicago]

D.

[Java ME: Jessy:Chicago, Java ME: Mark:Chicago][Java EE: Helen:Houston]

Full Access
Question # 20

Given the code fragment:

UnaryOperator uo1 = s -> s*2;line n1

List loanValues = Arrays.asList(1000.0, 2000.0);

loanValues.stream()

.filter(lv -> lv >= 1500)

.map(lv -> uo1.apply(lv))

.forEach(s -> System.out.print(s + “ “));

What is the result?

A.

4000.0

B.

4000

C.

A compilation error occurs at line n1.

D.

A compilation error occurs at line n2.

Full Access
Question # 21

Given the code fragment:

What is the result?

A.

text1text2

B.

text1text2text2text3

C.

text1

D.

[text1, text2]

Full Access
Question # 22

Given:

public class Customer {

private String fName;

private String lName;

private static int count;

public customer (String first, String last) {fName = first, lName = last;

++count;}

static { count = 0; }

public static int getCount() {return count; }

}

public class App {

public static void main (String [] args) {

Customer c1 = new Customer(“Larry”, “Smith”);

Customer c2 = new Customer(“Pedro”, “Gonzales”);

Customer c3 = new Customer(“Penny”, “Jones”);

Customer c4 = new Customer(“Lars”, “Svenson”);

c4 = null;

c3 = c2;

System.out.println (Customer.getCount());

}

}

What is the result?

A.

0

B.

2

C.

3

D.

4

E.

5

Full Access
Question # 23

Which two reasons should you use interfaces instead of abstract classes? (Choose two.)

A.

You expect that classes that implement your interfaces have many common methods or fields, or require access modifiers other than public.

B.

You expect that unrelated classes would implement your interfaces.

C.

You want to share code among several closely related classes.

D.

You want to declare non-static on non-final fields.

E.

You want to take advantage of multiple inheritance of type.

Full Access
Question # 24

Given the code fragment:

What is the result?

A.

Word: why what when

B.

Word: why Word: why what Word: why what when

C.

Word: why Word: what Word: when

D.

Compilation fails at line n1.

Full Access
Question # 25

Given the code fragment:

Which code fragment, when inserted at line n1, ensures false is printed?

A.

boolean b = cs.stream() .findAny() .get() .equals(“Java”);

B.

boolean b = cs.stream() .anyMatch (w -> w.equals (“Java”));

C.

boolean b = cs.stream() .findFirst() .get() .equals(“Java”);

D.

boolean b = cs.stream() .allMatch(w -> w.equals(“Java”));

Full Access
Question # 26

Given the code fragments:

and

What is the result?

A.

Video played.Game played.

B.

A compilation error occurs.

C.

class java.lang.Exception

D.

class java.io.IOException

Full Access
Question # 27

Given:

From what threading problem does the program suffer?

A.

race condition

B.

deadlock

C.

starvation

D.

livelock

Full Access
Question # 28

Given the content:

and given the code fragment:

Which two code fragments, when inserted at line 1 independently, enable the code to print “Wie geht’s?”

A.

currentLocale = new Locale (“de”, “DE”);

B.

currentLocale = new Locale.Builder ().setLanguage (“de”).setRegion (“DE”).build();

C.

currentLocale = Locale.GERMAN;

D.

currentlocale = new Locale();currentLocale.setLanguage (“de”);currentLocale.setRegion (“DE”);

E.

currentLocale = Locale.getInstance(Locale.GERMAN,Locale.GERMANY);

Full Access
Question # 29

Given the code fragment:

Which should be inserted into line n1 to print Average = 2.5?

A.

IntStream str = Stream.of (1, 2, 3, 4);

B.

IntStream str = IntStream.of (1, 2, 3, 4);

C.

DoubleStream str = Stream.of (1.0, 2.0, 3.0, 4.0);

D.

Stream str = Stream.of (1, 2, 3, 4);

Full Access