Quiz: Multithreaded Debugging

Test yourself on the knowledge you learned about multithreaded debugging.

We'll cover the following...
Press + to interact
type PostgresConnectionObj struct {
host string
username string
password string
dbname string
port int
}
var dbConn *PostgresConnectionObj // Declaration of a global variable to hold the singleton instance.
// Getter methods for the PostgresConnectionObj fields.
func (p *PostgresConnectionObj) getHost() string {
return p.host
}
func (p *PostgresConnectionObj) getUser() string {
return p.username
}
func (p *PostgresConnectionObj) getPassword() string {
return p.password
}
func (p *PostgresConnectionObj) getDbName() string {
return p.dbname
}
func (p *PostgresConnectionObj) getPort() int {
return p.port
}
// Initialization function to create and initialize the singleton instance.
func initInstance() *PostgresConnectionObj {
if dbConn == nil { // Check if the singleton instance is not created yet.
dbConn = &PostgresConnectionObj{ // Create a new instance with default field values.
host: "hostname",
username: "admin",
password: "passwd",
dbname: "db",
port: 5432,
}
}
return dbConn // Return the singleton instance.
}

For questions 1–3, read through the code above and answer the questions below.

1

(Select all that apply.) What are the shared variables in the code above?

A)

The dbConn object

B)

Members of an instance of the dbConn struct

C)

No shared variables in the code

D)

Only the string members of the dbConn struct

Question 1 of 50 attempted
...