0% found this document useful (0 votes)
29 views14 pages

STD10-CPA-Assertion and Reasoning

The document consists of a series of assertion and reasoning questions related to programming concepts, particularly in Java. Each question presents an assertion and a corresponding reason, with multiple-choice answers that assess the truthfulness and explanatory relationship between the two. Topics covered include loops, conditional statements, constructors, and the Java compilation process.

Uploaded by

mh11bv2754
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views14 pages

STD10-CPA-Assertion and Reasoning

The document consists of a series of assertion and reasoning questions related to programming concepts, particularly in Java. Each question presents an assertion and a corresponding reason, with multiple-choice answers that assess the truthfulness and explanatory relationship between the two. Topics covered include loops, conditional statements, constructors, and the Java compilation process.

Uploaded by

mh11bv2754
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

STD10-CPA-ASSERTION AND REASONING QUESTIONS

1. Assertion: Using a loop is more efficient than writing repetitive code.


Reason: Loops help in reducing code redundancy and make maintenance easier.
a) Both Assertion and Reason are true and reason is the 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

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

12.Assertion: A constructor is a special method in a class that is automatically called when an


object is instantiated.
Reason: Constructors are used to initialize the object's state and perform setup tasks.
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

18. Assertion (A):class is needed for all kinds of operation or tasks.


Reason (R): The variables given within the class to perform some tasks are known as
instance 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

19. Assertion (A):class is a composite data type.


Reason (R): As it is created by using a set of primitive data types
(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

20. She is both a singer and a writer. which cops principle is exhibited here?

21. Assertion. Java is a platform independent language.


Reason: for Java Byte code is same for all operating systems
(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
21. I know how to drive a car but don't know how combustion engine works"

22. In nested loop, if break is present in the inner loop thin


a) It will exit only from Inner loop
b) from outer loop.
c) will exit the program

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

25. Assertion (A):class is needed for all kinds of operation or tasks,


Reason (R): The variables given within the class to perform some tasks are known as
member variables
(a)Both Assertion (A) and Reason (R) are true and Reason (R) 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

26. Assertion(A): constructor needs no return type.


Reason(R) it is only used to initialize the data members.
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)Assertions is correct but reason is false
d) Assertion is wrong and reason is true
27.

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.

You might also like