University of the People C1103 Programing 2 Graded Quiz Unit 6
Started on Thursday, 1 August 2024, 2:37 AM
State Finished
Completed on Thursday, 1 August 2024, 3:07 AM
Time taken 30 mins 2 secs
Marks 15.00/15.00
Grade 100.00 out of 100.00
Question 1
Correct
Mark 1.00 out of 1.00
Flag question
Question text
Which stream class is used to write formatted text to a file in Java?
Question 1 Answer
a. PrintWriter
b. FileWriter
c. FileOutputStream
d. BufferedWriter
Feedback
The correct answer is: PrintWriter
Question 2
Correct
Mark 1.00 out of 1.00
Flag question
Question text
How can you achieve covariance in generic programming?
Question 2 Answer
a. By using the "super" keyword
b. By using the "extends" keyword
c. By declaring generic types as final
d. By omitting the type parameter in method declarations
Feedback
The correct answer is: By using the "extends" keyword
Question 3
Correct
Mark 1.00 out of 1.00
Flag question
Question text
In Java, what does serialization refer to in the context of I/O Streams?
Question 3 Answer
a. Reading and writing characters
b. Reading and writing binary data
c. Reading and writing primitive data types
d. Reading and writing formatted text
Feedback
The correct answer is: Reading and writing binary data
Question 4
Correct
Mark 1.00 out of 1.00
Flag question
Question text
What is a potential drawback of using raw types in generic programming?
Question 4 Answer
a. Loss of type safety
b. Increased code readability
c. Improved performance
d. Compatibility with primitive types only
Feedback
The correct answer is: Loss of type safety
Question 5
Correct
Mark 1.00 out of 1.00
Flag question
Question text
How can you achieve type safety when working with collections in Java?
Question 5 Answer
a. By using raw types
b. By using generic types
c. By using wildcard types
d. By using any data type
Feedback
The correct answer is: By using generic types
Question 6
Correct
Mark 1.00 out of 1.00
Flag question
Question text
Which method is used to read a character from the FileReader class in Java?
Question 6 Answer
a. readChar()
b. read()
c. readLine()
d. readString()
Feedback
The correct answer is: read()
Question 7
Correct
Mark 1.00 out of 1.00
Flag question
Question text
Which interface is commonly used to iterate through all elements of a collection in
Java?
Question 7 Answer
a. Iterator
b. List
c. Iterable
d. Enumeration
Feedback
The correct answer is: Iterator
Question 8
Ccorrect
Mark 1.00 out of 1.00
Flag question
Question text
Which of the following is not a valid statement in JDBC?
Question 8 Answer
a. Statement
b. PreparedStatement
c. QueryStatement
d. CallableStatement
Feedback
The correct answer is: QueryStatement
Question 9
Correct
Mark 1.00 out of 1.00
Flag question
Question text
In JDBC, what interface is used to represent a SQL statement?
Question 9 Answer
a. SQLStatement
b. Statement
c. QueryInterface
d. PreparedStatement
Feedback
The correct answer is: Statement
Question 10
Correct
Mark 1.00 out of 1.00
Flag question
Question text
What happens if you try to instantiate a generic class with a primitive data type in
Java?
Question 10 Answer
a. It compiles successfully.
b. It results in a runtime exception.
c. It generates a compile-time error.
d. It automatically converts the primitive type to its wrapper class.
Feedback
The correct answer is: It generates a compile-time error.
Question 11
Correct
Mark 1.00 out of 1.00
Flag question
Question text
Which Java class is commonly used to represent a database connection in JDBC?
Question 11 Answer
a. Connection
b. DatabaseConnection
c. DBConnection
d. SQLConnection
Feedback
The correct answer is: Connection
Question 12
Correct
Mark 1.00 out of 1.00
Flag question
Question text
How is a connection to a database established in JDBC?
Question 12 Answer
a. Using ConnectionFactory
b. Through DriverManager
c. Using SQLConnection
d. Through DataSource
Feedback
The correct answer is: Through DriverManager
Question 13
Correct
Mark 1.00 out of 1.00
Flag question
Question text
What is the purpose of the setAutoCommit method in the Connection interface?
Question 13 Answer
a. Committing a transaction automatically
b. Setting the database URL
c. Establishing a connection
d. Configuring the JDBC driver
Feedback
The correct answer is: Committing a transaction automatically
Question 14
Correct
Mark 1.00 out of 1.00
Flag question
Question text
What is the role of the ObjectInputStream class in Java?
Question 14 Answer
a. Reading primitive data types
b. Writing primitive data types
c. Reading objects
d. Writing objects
Feedback
The correct answer is: Reading objects
Question 15
Correct
Mark 1.00 out of 1.00
Flag question
Question text
Which layout manager is commonly used in applets for arranging components in a
grid?
Question 15 Answer
a. FlowLayout
b. GridLayout
c. BorderLayout
d. CardLayout
Feedback
The correct answer is: GridLayout