BNM PUBLIC SCHOOL
Computer Applications
Class: 9
Assignment 2
Increment and Decrement Operators
Solve the given expressions using the following values accordingly:
Sl. No Expressions
i = 11
1.
i = i++ + ++i
a=11, b=22, c
2.
c = a + b + a++ + b++ + ++a + ++b
i=0
3.
i = i++ - --i + ++i - i--
i=1, j=2, k=3
4.
m = i-- - j-- - k--
a=1, b=2
5.
--b - ++a + ++b - --a
i=19, j=29, k
6.
k = i-- - i++ + --j - ++j + --i - j-- + ++i - j++
i = 11
7.
j = --(i++)
m = 0, n = 0
8.
p = --m * --n * n-- * m--
a=1
9.
a = a++ + ++a * --a - a--
i = 0, j = 0
10.
(--i * i++ * ++j * j++)
a = 2, b = 3, and c = 9
11.
a - (b++) * (--c)
a = 5, b = 9
12.
a += a++ - ++b + a
a=0, b=10, c=40
13.
a= --b + (c++) + b
m = 5 and n = 2
14.
n = m + m/n
a = 2, b = 3, and c = 9
15.
a * (++b) % c
Sl. No Incorrect Code Snippet /Statement Corrected Code Snippet /Statement
1. int x = 5
int a = 10;
int b = 20;
2.
boolean result = a = b;
[Link](result);
if (x > y
{
3.
[Link]("x is greater than y");
}
int x = 10;
int y = 20;
if (x > y) {
[Link]("x is greater than y");
}
else if (x < y) {
4.
[Link]("x is less than y");
}
else if (x > y)
{
[Link]("x is greater than y");
}
5. int 3x = 5;
int a = 5;
6. int b = 0;
int result = a / b;
7. int x = "10";
String name = "John";
8. int age = 25;
String result = name + age;
for (i = 1; i <= 5; i++
{
9.
[Link](i + "\n");
}
int num1 = 10;
10. double num2 = 3.14;
int result1 = num1 / num2;
BNM PUBLIC SCHOOL
Computer Applications
Class: 9
Assignment 3
Assertion and Reason
Choose the correct answer from the given below options for the following
questions:
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): OOP paradigm follows a problem-solving approach where all
computations are carried out using objects.
Reason(R): In OOP, more stress is given on objects rather than functions.
2. Assertion(A): String is a primitive data type.
Reason(R): String is an object type as [Link] package provides the String class.
3. Assertion(A): The index of last element of an array is equal to the number of
elements in the array.
Reason(R): Index of an array begins from 0.
4. Assertion(A): A derived class can be a base class for another class.
Reason(R): In multilevel inheritance, derived class can serve as base class.
5. Assertion(A): do while loop always executes at least once.
Reason(R): do while loop is an exit-controlled loop i.e., conditional expression is
evaluated after execution.
6. Assertion(A): Value of a variable cannot be fixed.
Reason(R): Variable’s value can be fixed by using final keyword.
7. Assertion(A): Increment and decrement operators are binary operators.
Reason(R): Increment and decrement operators require only one operand.
8. Assertion(A): Pure methods is also known as Accessor.
Reason(R): Impure functions can cause side effects.
9. Assertion(A): A local variable can’t use any access specifier.
Reason(R): Local variable is declared in method, constructor or block.
10. Assertion(A): In static method, memory allocation happens only once.
Reason(R): Static keyword fixes a particular memory location for that method in
ROM.