Core Java Assessment

Core Java Assessment

Professional Development

25 Qs

quiz-placeholder

Similar activities

Season 4 #Spaic Python Weekly Quiz

Season 4 #Spaic Python Weekly Quiz

KG - Professional Development

20 Qs

Technical vocab

Technical vocab

9th Grade - Professional Development

20 Qs

Java Fundamentals

Java Fundamentals

Professional Development

20 Qs

Roblox bedwars quiz

Roblox bedwars quiz

Professional Development

22 Qs

CÂU LỆNH WHILE

CÂU LỆNH WHILE

Professional Development

21 Qs

Firewall dan Proxy

Firewall dan Proxy

Professional Development

20 Qs

คุณรู้จัก Digital Technology หรือไม่

คุณรู้จัก Digital Technology หรือไม่

Professional Development

20 Qs

Formulas & Functions in Excel (Post)

Formulas & Functions in Excel (Post)

Professional Development

20 Qs

Core Java Assessment

Core Java Assessment

Assessment

Quiz

Computers

Professional Development

Practice Problem

Hard

Created by

Ananth Kumar

Used 13+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

25 questions

Show all answers

1.

MULTIPLE SELECT QUESTION

3 mins • 1 pt

Given that you are working with a JDBC 4.0 driver, which three are required for this JDBC driver to be compliant?

Must include a META-INF/services/java.sql.Driver file

Must provide implementations of Driver, Connection, Statement, and ResultSet interfaces

Must support scrollable ResultSets

Must support PreparedStatement and CallableStatement

Must support transactions

2.

MULTIPLE SELECT QUESTION

3 mins • 1 pt

Which three are available through an instance of DatabaseMetaData?

The number of rows returned

The name of the JDBC driver

The default transaction isolation level

The last query used

The names of stored procedures in the database

3.

MULTIPLE SELECT QUESTION

3 mins • 1 pt

Given this code fragment:

Statement stmt = conn.createStatement();

ResultSet rs;

String query = "<QUERY HERE>";

stmt.execute(query);

if ((rs = stmt.getResultSet()) != null) {

System.out.println("Results");

}

if (stmt.getUpdateCount() > -1) {

System.out.println("Update");

}

Which query statements entered into <QUERY HERE> produce the output that follows the query string (in the following answer), assuming each query is valid? (Choose all that apply.)

"SELECT * FROM Customer"

Results

. "INSERT INTO Book VALUES ('1023456789', 'One Night in Paris', '1984-10-20',

'Hardcover', 13.95)"

Update

"UPDATE Customer SET Phone = '555-234-1021' WHERE CustomerID = 101"

Update

"SELECT Author.LastName FROM Author"

Results

. "DELETE FROM Book WHERE ISBN = '1023456789'"

Update

4.

MULTIPLE SELECT QUESTION

3 mins • 1 pt

Given:

String call = "{CALL REMOVEBOOKS(?, ?)}";

String titleToRemove = null;

int maxBooks = 0;

CallableStatement cstmt = conn.prepareCall(call);

String titles = "%Hero%";

int numBooksRemoved;

// Code added here

If REMOVEBOOKS is a stored procedure that takes an INOUT integer parameter as its first argument and an IN String parameter as its second argument, which code blocks, when placed at the line

// Code added here, could correctly execute the stored procedure and return a result?

cstmt.setInt(0, maxBooks);

cstmt.setString(1, titleToRemove);

cstmt.registerOutParameter(0, java.sql.Types.INTEGER);

cstmt.execute();

numBooksRemoved = cstmt.getInt(0);

cstmt.setInt(1, maxBooks);

cstmt.setString(2, titleToRemove);

cstmt.registerOutParameter(1, java.sql.Types.INTEGER);

cstmt.executeQuery(query);

numBooksRemoved = cstmt.getInt(1);

cstmt.setInt(1, maxBooks);

cstmt.setString(2, titleToRemove);

cstmt.execute();

cstmt.registerOutParameter(1, java.sql.Types.INTEGER);

numBooksRemoved = cstmt.getInt(1);

cstmt.setInt(1, maxBooks);

cstmt.setString(2, titleToRemove);

cstmt.registerOutParameter(1, java.sql.Types.INTEGER);

ResultSet rs = cstmt.executeQuery();

rs.next();

numbBooks = rs.getInt(1);

cstmt.setInt(1, maxBooks);

cstmt.setString(2, titleToRemove);

cstmt.registerOutParameter(1, java.sql.Types.INTEGER);

cstmt.execute();

numBooksRemoved = cstmt.getInt(1);

5.

MULTIPLE SELECT QUESTION

3 mins • 1 pt

Assume you have a class that holds two private variables: a and b. Which of the following pairs can prevent concurrent access problems in that class? (Choose all that apply.)

public synchronized int read(){return a+b;}

public synchronized void set(int a, int b){this.a=a;this.b=b;}

public int read(){synchronized(a){return a+b;}}

public void set(int a, int b){synchronized(a){this.a=a;this.b=b;}}

public int read(){synchronized(a){return a+b;}}

public void set(int a, int b){synchronized(b){this.a=a;this.b=b;}}

public synchronized(this) int read(){return a+b;}

public synchronized(this) void set(int a, int b){this.a=a;this.b=b;}

public int read(){synchronized(this){return a+b;}}

public void set(int a, int b){synchronized(this){this.a=a;this.b=b;}}

6.

MULTIPLE SELECT QUESTION

3 mins • 1 pt

public class TwoThreads {

static Thread laurel, hardy;

public static void main(String[] args) {

laurel = new Thread() {

public void run() {

System.out.println("A");

try {

hardy.sleep(1000);

} catch (Exception e) {

System.out.println("B");

}

System.out.println("C");

}

};

hardy = new Thread() {

public void run() {

System.out.println("D");

try {

laurel.wait();

} catch (Exception e) {

System.out.println("E");

}

System.out.println("F");

}

};

laurel.start();

hardy.start();

}

}

Which letters will eventually appear somewhere in the output? (Choose all that apply.)

A

C

D

E

F

7.

MULTIPLE SELECT QUESTION

3 mins • 1 pt

This class is intended to allow users to write a series of messages so that

each message is identified with a timestamp and the name of the thread that wrote the message:

public class Logger {

private StringBuilder contents = new StringBuilder();

public void log(String message) {

contents.append(System.currentTimeMillis());

contents.append(": ");

contents.append(Thread.currentThread().getName());

contents.append(message);

contents.append("\n");

}

public String getContents() { return contents.toString(); }

}

How can we ensure that instances of this class can be safely used by multiple threads?

This class is already thread-safe

Replacing StringBuilder with StringBuffer will make this class thread-safe

Synchronize the log() method only

Synchronize the getContents() method only

Synchronize both log() and getContents()

Create a free account and access millions of resources

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

By signing up, you agree to our Terms of Service & Privacy Policy

Already have an account?