STD10-CPA-Assertion and Reasoning
STD10-CPA-Assertion and Reasoning
2. Assertion: The "while" loop in Java executes a block of code repeatedly as long as the
given condition is true. Reason: It provides a way to implement indefinite iteration
in a program.
a)Both Assertion and Reason are true and reason is correct explanation of the Assertion
b) Both Assertion and Reason are true and reason is not a correct explanation of the assertion
c) Assertion is true and Reason is false
d) Assertion is false and Reason is true
3. Assertion: Switch statements can only be used with integer data types in Java.
Reason: Switch statements are used to compare a single value against a list of possible
values.
(a) Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of
Assertion (A)
(b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation
of Assertion (A)
(c) Assertion (A) is true and Reason (R) is false
(d) Assertion (A) is false and Reason (R) is true
4. Assertion: Conditional statements allow a program to make decisions based on certain
conditions.
Reason: They help in controlling the flow of the program by executing different code
blocks depending on whether a condition is true or false.
(a) Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of
Assertion (A)
(b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation
of Assertion (A)
(c) Assertion (A) is true and Reason (R) is false
(d) Assertion (A) is false and Reason (R) is true
5. Assertion(A): The "if-else" statement allows a program to execute different code blocks
based on the evaluation of a condition.
Reason(R): It provides a way to create branching paths in the program's execution flow.
a) Both Assertion and Reason are true and reason is correct explanation of the Assertion
b) Both Assertion and Reason are true and reason is not a correct explanation of the assertion
c) Assertion is true and Reason is false
d) Assertion is false and Reason is true
6. The following program segment must print the square root of a number(n) if the user input
the choice as 's', otherwise it must print the cube root of a number(n). However the code
has some errors. Fix the code to get appropriate result as per user's choice.
int n=sc.nextInt();
char choice = sc.nextChar();
if(choice='s')
System.out.printin (Math.cbrt(n));
else
System.out.println (Math.sqrt(n));
7. The following code segment should print "You can go out" if you have done your
homework (dih) and cleaned your room(cr). However, the code has errors. Fix the code so
that it compiles and runs correctly.
boolean dh = True; boolean cr= true;
if (dh && cr) System.out.println("You cannot go out");
else
System.out.println("You can go out");
8. Assertion: Unboxing is opposite of autoboxing. Reasoning, It's a system of converting an
object of wrapper class into primitive data type
a) Both assertion and reason are correct and reason is correct explanations of the assertion
b) Both assertion and reason are correct but reason is not correct explanations of the
assertion
c) Assertion is correct but reason is false
d)Assertion is wrong and reason is true
8. Assertion: In Java, the "String" class is used to create and manipulate strings, and it is
immutable.
Reason: Immutability ensures that once a string object is created, its value cannot be
changed.
a)Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of
Assertion (A)
b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation of
Assertion (A)
(c) Assertion (A) is true and Reason (R) is false
(d) Assertion (A) is false and Reason (R) is true
9. Assertion (A): String is a class Reason (R): String class belongs to the lang package
a) Only Assertion(A) is correct
b) Both Assertion(A) and Reason (R) are correct
c) Both are incorrect
d) Only Reason(R) is correct
10. Assertion: Arrays are used to store multiple values of the same data type in a single
variable.
Reason: Arrays provide better memory utilization compared to individual variables.
(a)Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of
Assertion (A)
(b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation
of Assertion (A)
(c) Assertion (A) is true and Reason (R) is false
(d) Assertion (A) is false and Reason (R) is true
11.Assertion (A): An array is a collection of values having common name and datatype.
Reason (R): It is a primitive datatype.
a) Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of
Assertion (A)
b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation of
Assertion (A)
(c) Assertion (A) is true and Reason (R) is false
(d) Assertion (A) is false and Reason (R) is true
13. Assertion: Functions in programming help in modularizing code for better organization.
Reason: Functions allow code reusability by encapsulating a set of instructions that can be
used multiple times.
(a) Both Assertion(A) and Reason(R) are true and Reason(R) is a correct explanation of
Assertion(A)
(b) Both Assertion (A) and Reason (R) are true and Reason (R) b is not a correct explanation
of Assertion(A)
(c) Assertion (A) is true and Reason (R) is false
(d) Assertion (A) is false and Reason (R) is true
14. Assertion(A): call by value is known as pure method Reason (R): The original value of
variables does not change as operation is performed on copied values of variables
a) Both Assertion(A) and Reason(R) are true and Reason(R) is a correct explanation of
Assertion(A)
(b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation
of Assertion(A)
(c) Assertion (A) is true and Reason (R) is false
(d) Assertion (A) is false and Reason (R) is true
15. Assertion (A): Two or more methods sharing same name can have same number of
parameters and datatype. Reason (R): Method overloading implements Polymorphism.
(a) Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of
Assertion (A)
(b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation
of Assertion (A)
(c) Assertion (A) is true and Reason (R) is false
(d) Assertion (A) is false and Reason (R) is true
16. Assertion (A): A method in Java is a block of code that, when called, performs specific
actions mentioned in it. Reason (R):Pure methods take objects and/or primitive data types as
arguments and modify the
arguments. (a)Both Assertion (A) and Reason (R) are true and Reason (R) is correct
explanation of Assertion (A)
(b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation
of Assertion (A)
(e) Assertion (A) is true and Reason (R) is false
(d) Assertion (A) is false and Reason (R) is true
17. Assertion (A) A method in Java is a block of code that, when called, performs specific
actions mentioned in it. Reason (R) Pure methods take objects and/or primitive data types as
arguments and modify the arguments.
(a)Both Assertion (A) and Reason (R) are true and Reason (R) is correct explanation of
Assertion (A)
(b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation
of Assertion (A)
(c) Assertion (A) is true and Reason (R) is false
(d) Assertion (A) is false and Reason (R) is true
20. She is both a singer and a writer. which cops principle is exhibited here?
23.What is the final value of ctr when the iteration process given below, executes?
int ctr=0;
for(int i=1;i<=5;i++)
for(int j=1;j<=5;j+=2)
++ctr;
24. Assertion(A); formal parameters are also said to be arguments passed to method.
Reason(R): because they receive value from is caller method.
a) Both assertion and reason are correct and reason is correct explanations of the assertion
b)Both assertion and reason are correct but reason is not correct explanations of the assertion
e)Assertions is correct but reason is false
d) Assertion is wrong and reason is true
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
CHAPTER 1
41. Assertion: Object-oriented programming (OOP) emphasizes the concept of objects and
classes as fundamental units for structuring code.
Reason: OOP facilitates better code organization by encapsulating data and methods within
objects.
42. Assertion: Java source code is human-readable code written by developers to create Java
programs.
Reason: Java source code is written in plain text using Java syntax and conventions. It
contains instructions understandable to programmers and serves as the input to the Java
compiler, which translates it into bytecode.
43. Assertion: Bytecode is an intermediate representation of Java code generated during the
compilation process.
Reason: When Java source code is compiled, it is translated by the Java compiler into
bytecode.
44. Assertion: Object code is the machine-readable code generated by the Java compiler
directly from Java source code.
Reason: Unlike many other programming languages, Java does not generate traditional
object code directly from the source code.
45. Assertion: The Java Virtual Machine (JVM) is an integral part of the Java platform
responsible for executing Java bytecode.
Reason: The JVM is a virtual machine that interprets or just-in-time (JIT) compiles bytecode
into machine code, allowing Java programs to run on any device or platform that has a
compatible JVM installed. Assertion 5: The Java compilation process involves translating
Java source code into bytecode.