Page 98 - CA_Blue( J )_Class10
P. 98
System.out.println(a + " " + b + " " + c);
a. 25 4.5 Hello b. 25 4 Hello
c. 25 4.5 Hello25 d. 25.0 4.5 Hello
10. Which of the following is a type of runtime error in Java?
a. Syntax Error b. Logic Error
c. Exception d. Compilation Error
B. Fill in the blanks.
1. Forgetting to put a semicolon at the end of a statement is a type ………………… error.
2. An ………………… is a situation in which the execution of a program stops abnormally.
3. ………………… errors are also called semantic errors.
4. In Java, the ………………… class is commonly used to read input from the user, and it includes methods such as …………………,
…………………, and ………………… for reading different types of data.
5. We use ………………… arguments to input values in String format in the main( ) method.
C. Answer the following questions:
1. What is the difference between multiline comments and documentation comments?
2. Write the syntax to input a Short type value using the Scanner class?
3. What are the three types of errors?
4. Define logical error. Give an example.
5. Write the difference between try and catch.
D. Assertion and Reasoning based questions.
The following questions consist of two statements – Assertion (A) and Reason (R). Answer these questions by selecting the
appropriate option given below:
a. Both A and R are true, and R is the correct explanation of A.
b. Both A and R are true, but R is not the correct explanation of A.
c. A is true, but R is false.
d. A is false, but R is true.
1. Assertion (A): Comments in Java are compiled into the bytecode and can affect the performance of the application.
Reason(R): Comments are included in the source code to provide explanations and do not affect the runtime behaviour of the
code.
2. Assertion (A): The java.lang package is automatically imported into every Java program.
Reason (R): The java.lang package contains fundamental classes such as String, System, and Math.
3. Assertion (A): ArithmeticException is thrown when a division by zero occurs.
Reason (R): ArithmeticException is a runtime exception that indicates an exceptional arithmetic condition.
4. Assertion (A): IOException is a logical error.
Reason (R): IOException occurs during input and output operations and must be caught or declared to be thrown in the method
signature.
21 st
E. Case-based questions. Century #Experiential Learning
Skills
1. Jake implements a method to add a new book to the inventory. He adds a comment to explain the method's logic and parameters.
class LibraryManager
{
void addBook(String title)
{
// Code to add the book to the inventory
}
}
9696 Touchpad Computer Applications-X

