5/20/24, 1:31 PM Chapter 4: Operators in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ
pplications with BlueJ Java | KnowledgeBoat
STUDY MATERIAL LOGIN JOIN NOW
Home / Class 10 - Logix Kips ICSE Computer Applications with BlueJ / Operators in Java
CONTENTS
Chapter 4
Search by lesson title
Operators in Java Multiple Choice Questions
Chapter 1 State whether the given
Class 10 - Logix Kips ICSE Computer Applications with BlueJ statements are True or False
Object Oriented Programming Concepts
Assignment Questions
Chapter 2
Introduction to Java
Chapter 3
Values and Data Types
Kingston Thumb Drives
Chapter 4
Operators in Java
Store your data on the go without needing internet
Chapter 5 connection.
User-Defined Methods
Chapter 6
Input in Java
Chapter 7 Kingston Technology Learn More
Mathematical Library Methods
Chapter 8
Conditional Constructs in Java
Multiple Choice Questions
Chapter 9
Iterative Constructs in Java
Question 1
Chapter 10
Nested for loops
If a = 8 and b = 4, the value of a %= b is ...........
Chapter 11
Constructors
1. 2
2. 0 ✓
3. 4
4. 8
Explanation
a %= b
⇒a=a%b
⇒a=8%4 [Putting values of a & b]
⇒a=0
% is modulo operator that returns the remainder of the
division operation. Dividing 8 by 4 gives 2 as quotient and 0
as remainder so the final answer is 0.
Question 2
An operator taking only single operand for its operation is called
...........
1. A unary operator ✓
2. A binary operator
3. A ternary operator
4. None of these
Question 3
Which one of the following is not a binary operator?
1. AND
[Link] 1/17
5/20/24, 1:31 PM Chapter 4: Operators in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
2. %
3. ==
4. ! ✓
Explanation
! is the NOT operator that works on only one operand so it is a
unary operator not a binary operator.
Question 4
Which one of the following is not a valid operator in Java?
1. <=
2. !== ✓
3. !=
4. ==
Question 5
The statement i = i + 1 is equivalent to ...........
1. i++
2. i += 1
3. ++i
4. All of these ✓
Explanation
All the 3 statements increment the value of i by 1.
Question 6
For x = 5, the statement sum = ++x + 8 evaluates to ...........
1. sum = 12
2. sum = 13
3. sum = 14 ✓
4. sum = 15
Explanation
sum = ++x + 8
⇒ sum = 6 + 8
⇒ sum = 14
++x will first increment the value of x from 5 to 6 and then use
this incremented value in the expression.
Question 7
Assuming x = 1 with the following code snippet:
int y = --x;
Which one of the following is true?
1. x=1, y=1
[Link] 2/17
5/20/24, 1:31 PM Chapter 4: Operators in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
2. x=0, y=0 ✓
3. x=1, y=0
4. x=0, y=1
Explanation
--x will first decrement the value of x from 1 to 0 and then
assign the decremented value to y so both x and y will be 0.
Question 8
The statement (1>0) && (1<0) evaluates to ...........
1. 0
2. 1
3. false ✓
4. true
Explanation
1>0 is true and 1<0 is false so the condition becomes true &&
false . As && return true only when both of its operands are true
so the answer is false.
Question 9
The statement (1>0) || (1<0) evaluates to ...........
1. 0
2. 1
3. false
4. true ✓
Explanation
1>0 is true and 1<0 is false so the condition becomes true ||
false . As || return true if one or both of its operands are true so
the answer is true.
Question 10
The statement (1==1)? 1: 0 evaluates to ...........
1. 0
2. 1 ✓
3. false
4. true
Explanation
1==1 is true so the expression just after the question mark (which
in this case is 1) is returned.
Question 11
The expression 17 % 4 gives the output ...........
[Link] 3/17
5/20/24, 1:31 PM Chapter 4: Operators in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
1. 4
2. 3
3. 2
4. 1 ✓
Explanation
% is modulus operator that returns the remainder of the
division operation. Dividing 17 by 4 gives 4 as quotient and 1
as remainder so the final answer is 1.
Question 12
Consider the following code snippet:
float x = 8.25F;
int y;
y = (int) x;
What are the values of x and y?
1. x= 8.25, y = 8 ✓
2. x = 8.0, y = 8.0
3. x = 8, y = 8.25
4. x = 8, y = 8
Explanation
When float value is casted to an int, the digits after the decimal
sign are discarded so y is assigned a value of 8.
Question 13
The expression 13 / 3 gives the output ...........
1. 4 ✓
2. 3
3. 0
4. 1
Explanation
When both operands of division operator (/) are integers then
integer division takes place discarding the digits after the decimal
sign.
Question 14
The statement [Link]("six " + 3 + 3); gives the output
...........
1. six 33 ✓
2. six 6
3. 33 six
4. 6 six
[Link] 4/17
5/20/24, 1:31 PM Chapter 4: Operators in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Explanation
First "six " + 3 is evaluated. As one operand of addition operator
(+) is string and other int so int is converted to string and
concatenation is performed resulting in "six 3". Next, "six 3" + 3
is evaluated and similarly the result is six 33.
Question 15
The expression 4 + 8 % 2 gives the output ...........
1. 6
2. 8
3. 4 ✓
4. None of these
Explanation
4+8%2
⇒4+0
⇒4
Due to operator precedence 8 % 2 is evaluated first. Its result is 0
so final result is 4.
Question 16
Implicit type conversion is also known as ...........
1. Automatic type conversion
2. Type promotion
3. Widening conversion
4. All of these ✓
State whether the given statements are True or False
Question 1
There is only one ternary operator in Java.
True
Question 2
Arithmetic operators + and - also have a unary form.
True
Question 3
Operators = and == perform the same operation in Java.
False
Question 4
The expression 14 % 2 evaluates to 0.
True
Question 5
[Link] 5/17
5/20/24, 1:31 PM Chapter 4: Operators in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
The expression 7 / 13 evaluates to 0.
True
Question 6
The output of [Link](!true); is false.
True
Question 7
The expressions 6 + 7 and "6" + "7" evaluate to the same value.
False
Question 8
The expression m = m + 2 is same as m =+ 2.
False
Question 9
The new operator allocates memory during runtime.
True
Question 10
The statements n = 25 and n == 25 are same.
False
Question 11
The expression p =- 9 is same as p = p-9.
False
Question 12
The assignment operator (=) is a binary operator.
True
Question 13
The output of [Link](1==1); is true.
True
Question 14
Explicit type conversion is also known as coercion.
False
Assignment Questions
Question 1
We have two variables x and y. Write Java statements to calculate
the result of division of y by x and calculate the remainder of the
division.
Answer
int quotient = y / x;
int remainder = y % x;
[Link] 6/17
5/20/24, 1:31 PM Chapter 4: Operators in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Question 2
Assign the value of pi (i.e., 3.142) to a variable with requisite data
type.
Answer
float pi = 3.142f;
Question 3
What are logical operators? Give an example of each.
Answer
Logical operators operate only on boolean operands and are used
to construct complex decision-making expressions. Some of the
logical operators are given below:
Operator Symbol
Logical AND &&
Logical OR ||
Logical NOT !
Question 4
What is an assignment operator? Give an example.
Answer
Assignment operator is used to assign the value of an expression
to a variable. It has the following syntax:
variable = expression;
For example,
totalMarks = 780;
The above statement assigns the value of 780 to the variable
totalMarks. Any previous value stored in totalMarks variable is
overwritten by this new value.
Question 5
Explain the shorthand assignment operator with an example.
Answer
Java provides shorthand assignment operators for all the
arithmetic binary operators. Shorthand assignment operators
follow the below syntax:
variable = variable operation expression;
[Link] 7/17
5/20/24, 1:31 PM Chapter 4: Operators in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Taking the example of shorthand addition operator, the expression
x = x + 3 can be rewritten as x += 3;
Question 6
What is the purpose of the new operator?
Answer
The new operator is used to allocate memory for the object.
Question 7
What is the use and syntax of a ternary operator?
Answer
Ternary operator is used to check if a condition is true and false.
Depending on whether the condition tests true or false, expression
1 or expression 2 is evaluated. Its syntax is:
boolean-expression ? expression1 : expression2;
Question 8
State the difference between = and ==.
Answer
= ==
It is the assignment operator It is the equality operator used
used for assigning a value to check if a variable is equal to
to a variable. another variable or literal.
E.g. int a = 10; assigns 10 E.g. if (a == 10) checks if
to variable a. variable a is equal to 10 or not.
Question 9
If a = 5, b = 9, calculate the value of:
a += a++ - ++b + a
Answer
a += a++ - ++b + a
⇒ a = a + (a++ - ++b + a)
⇒ a = 5 + (5 - 10 + 6)
⇒a=5+1
⇒a=6
a++ first uses the current value of a (which is 5) in the expression
and then increments it to 6. ++b first increment the current value of
b to 10 and uses this incremented value in the expression.
Question 10
Distinguish between the following:
[Link] 8/17
5/20/24, 1:31 PM Chapter 4: Operators in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
a. Prefix and Postfix Increment
Answer
Prefix Increment Postfix Increment
It works on the principle of It works on the principle of first
first increment, then use. use, then increment.
It (++) is written before the It (++) is written after the
operand. operand.
Example:
Example:
int a = 99;
int a = 99;
int b = a++;
int b = ++a;
After the execution of these two
After the execution of these
statements, a will have the
two statements, both a and
value of 100 and b will have the
b will have the value of 100.
value of 99.
b. Prefix and Postfix Decrement
Answer
Prefix Decrement Postfix Decrement
It works on the principle of It works on the principle of first
first decrement, then use. use, then decrement.
It (--) is written before the It (--) is written after the
operand. operand.
Example:
Example:
int a = 100;
int a = 100;
int b = a--;
int b = --a;
After the execution of these two
After the execution of these
statements, a will have the value
two statements, both a and
of 99 and b will have the value
b will have the value of 99.
of 100.
c. Unary and Binary Operators
Answer
Unary Operators Binary Operators
It operates on a single operand It operates on two operands
Increment (++) and Decrement Multiplication (*) and Division
(--) operators are examples of (/) are examples of Binary
Unary Arithmetic Operators Arithmetic Operators
d. Increment and Decrement Operator
Answer
[Link] 9/17
5/20/24, 1:31 PM Chapter 4: Operators in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Increment Operator Decrement Operator
Increment operators Decrement operators
increment the value of their decrement the value of their
operand by 1. operand by 1.
Increment operators are Decrement operators are
represented by ++ symbol. represented by -- symbol.
e. / and % operator
Answer
/ %
It is the Division operator It is the Modulus operator
Returns the quotient of Returns the remainder of
division operation division operation
Example: int a = 5 / 2; Here a Example: int b = 5 % 2; Here b
will get the value of 2 which will get the value of 1 which is
is the quotient of this division the remainder of this division
operation operation
Question 11
If m=5, n=2; what will be the output of m and n after execution?
i. m -= n ii. n = m + m/n
Answer
i. m -= n
⇒m=m-n
⇒m=5-2
⇒m=3
ii. n = m + m/n
⇒ n = 5 + 5/2
⇒n=5+2
⇒n=7
Question 12
If x = 3, y = 7, calculate the value of:
x -= x++ - ++y
Answer
x -= x++ - ++y
⇒ x = x - (x++ - ++y)
⇒ x = 3 - (3 - 8)
⇒ x = 3 - (-5)
⇒x=3+5
⇒x=8
Question 13
[Link] 10/17
5/20/24, 1:31 PM Chapter 4: Operators in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
What will be the output of the following if x=5?
i. 5 * ++x
ii. 5 * x++
Answer
i. 5 * ++x
⇒5*6
⇒ 30
ii. 5 * x++
⇒5*5
⇒ 25
Question 14
What is type conversion? How is an implicit type conversion
different from explicit type conversion?
Answer
Type conversion is a process that converts a value of one data
type to another data type.
In an implicit conversion, the result of a mixed mode expression is
obtained in the higher most data type of the variables without any
intervention by the user. For example:
int a = 10;
float b = 25.5f, c;
c = a + b;
In case of explicit type conversion, the data gets converted to a
type as specified by the programmer. For example:
int a = 10;
double b = 25.5;
float c = (float)(a + b);
Question 15
What do you understand by type conversion?
Answer
Type conversion is a process that converts a value of one data
type to another data type.
Question 16
Explain the term 'typecasting'.
Answer
The process of converting a value of one data type to another data
type is called typecasting.
Question 17
[Link] 11/17
5/20/24, 1:31 PM Chapter 4: Operators in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
What are precedence and associativity?
Answer
Precedence of operators refers to the order in which the operators
are applied to the operands in an expression.
Associativity of operators refers to the direction of execution of
operators ("Left to Right" or "Right to Left") when operators in an
expression have the same precedence.
Question 18
Evaluate the following expressions, if the values of the variables
are a = 2, b = 3 and c = 3
i. a - (b++) * (--c)
ii. a * (++b) %c
Answer
i. a - (b++) * (--c)
⇒2-3*2
⇒2-6
⇒ -4
ii. a * (++b) %c
⇒2*4%3
⇒8%3
⇒2
Question 19
Write the Java expressions for the following:
i. (a + b)2 + b
Answer
[Link](a+b, 2) + b
ii. a2 + b2
Answer
a*a+b*b
iii. z = x3 + y3 + (xy) / 3
Answer
z = [Link](x, 3) + [Link](y, 3) + x * y / 3
iv. f = a2 + b2 / a2 - b2
Answer
f = (a * a + b * b) / (a * a - b * b)
v. z = ab + bc + ca / 3abc
[Link] 12/17
5/20/24, 1:31 PM Chapter 4: Operators in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Answer
z = (a * b + b * c + c * a) / (3 * a * b * c)
vi. 0 <= x <= 50
Answer
x >= 0 && x <= 50
vii. a = (0.05 - 2y3) / x - y
Answer
a = (0.05 - 2 * y * y * y) / (x - y)
viii. (a + b)n / √3 + b
Answer
[Link](a+b, n) / ([Link](3) + b)
ix. ax + by / ∛x + ∛y
Answer
([Link](a, x) + [Link](b, y)) / ([Link](x) + [Link](y))
Question 20
Rewrite the following statements without using shorthand
operators.
a. p /= q
b. p -= 1
c. p *= q + r
d. p -= q - r
Answer
a. p = p / q
b. p = p - 1
c. p = p * (q + r)
d. p = p - (q - r)
Question 21
Determine the output of the following program.
public class Test
{
public static void main(String[] args)
{
int a = 1, b = 2;
[Link]("Output1: " + a + b);
[Link]("Output2: " + (a + b));
}
}
Output
[Link] 13/17
5/20/24, 1:31 PM Chapter 4: Operators in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Output1: 12
Output2: 3
Explanation
In the first println statement, the expression is "Output1: " + a +
b . First "Output1: " + a is evaluated. As one operand of addition
operator is string and other is int so int is casted to string and
concatenated giving the result as "Output1: 1". After that,
"Output1: 1" + 2 is evaluated and similarly the result is Output1:
12.
In second println statement, the expression is "Output2: " + (a + b).
Due to brackets, (a + b) is evaluated first. As both operands are
integers so they are added giving the result as 3. After that,
"Output2: " + 3 is evaluated, resulting in "Output2: 3".
Question 22
What is the difference between the following two statements in
terms of execution? Explain the results.
x -= 5;
x =- 5;
Answer
The first statement, x -= 5; subtracts 5 from x and assigns the
result back to x. It is equivalent to x = x - 5;
The second statement, x =- 5; assigns the value of -5 to x.
Question 23
What is concatenation? On which data type is concatenation
performed?
Answer
Concatenation means joining two strings together. It is performed
on String data type.
Question 24
Determine the output of the following program.
public class PredictOutput1
{
public static void main(String args[])
{
int a = 4, b = 2, c = 3;
[Link]("Output 1: " + (a = b * c));
[Link]("Output 2: " + (a = (b * c)));
}
}
Output
Output 1: 6
[Link] 14/17
5/20/24, 1:31 PM Chapter 4: Operators in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Output 2: 6
Explanation
In the first println statement, the expression is (a = b * c) . * has
higher precedence than = so first b and c are multiplied and after
that the result is assigned to a. Assignment operator returns the
value of the assignment so the result of this (a = b * c) entire
expression is 6.
In the second println statement, the expression is (a = (b * c)) .
Putting b * c in brackets causes b * c to be evaluated first but the
result is same as the first println statement as * has higher
precedence than =.
Question 25
Determine the output of the following program.
public class PredictOutput2
{
public static void main(String args[])
{
int a = 6, b = 2, c = 3;
[Link]("Output 1: " + (a == b * c));
[Link]("Output 2: " + (a == (b * c)));
}
}
Output
Output 1: true
Output 2: true
Explanation
b * c results in 6 which is equal to the value of a so true is printed
in both the cases.
Question 26
Determine the output of the following program.
public class PredictOutput3
{
public static void main(String args[])
{
int a = 2, b = 2, c = 2;
[Link]("Output 1: " + (a + 2 < b * c));
[Link]("Output 2: " + (a + 2 < (b * c)));
}
}
Output
Output 1: false
Output 2: false
Explanation
[Link] 15/17
5/20/24, 1:31 PM Chapter 4: Operators in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
In the first println statement, the expression is (a + 2 < b * c) . b
* c is evaluated first as * has higher precedence than + and <. After
that a + 2 is evaluated as between + and <, + has higher
precedence. Comparison is done in the end. As 4 < 4 is false so
false is printed. The case of second println statement is similar.
Prev Next
Values and Data Types User-Defined Methods
ICSE/ISC TEXTBOOK SOLUTIONS STUDYLIST COMPANY
Class - 6 Concise Biology Selina Solutions Java Pattern Programs About Us
Class - 6 Veena Bhargava Geography Solutions Java Series Programs Contact Us
Class - 6 Effective History & Civics Solutions Java Number Programs (ICSE Classes 9 / 10) Privacy Policy
Class - 6 APC Understanding Computers Solutions Java Number Programs (ISC Classes 11 / 12) Terms of Service
Class - 7 Concise Physics Selina Solutions Output Questions for Class 10 ICSE Computer Applications
Class - 7 Concise Chemistry Selina Solutions Algorithms & Flowcharts for ICSE Computers
Class - 7 Dalal Simplified Middle School Chemistry Solutions ICSE Class 8 Computers Differentiate Between the Following
Class - 7 Concise Biology Selina Solutions CBSE TEXTBOOK SOLUTIONS
Class - 7 Living Science Biology Ratna Sagar Solutions Class - 8 NCERT Science Solutions
Class - 7 Around the World Geography Solutions Class - 9 NCERT Science Solutions
Class - 7 Veena Bhargava Geography Solutions Class - 9 NCERT Geography Contemporary India 1 Solutions
Class - 7 Effective History & Civics Solutions Class - 9 Sumita Arora Computer Code 165 Solutions
Class - 7 APC Understanding Computers Solutions Class - 9 Kips Cyber Beans Computer Code 165 Solutions
Class - 8 Concise Physics Selina Solutions Class - 10 NCERT Mathematics Solutions
Class - 8 Concise Chemistry Selina Solutions Class - 10 NCERT Science Solutions
Class - 8 Dalal Simplified Middle School Chemistry Solutions Class - 10 NCERT Geography Contemporary India 2 Solutions
Class - 8 Concise Biology Selina Solutions Class - 10 NCERT History India & Contemporary World 2 Solutions
Class - 8 Living Science Biology Ratna Sagar Solutions Class - 10 Sumita Arora Computer Code 165 Solutions
Class - 8 Around the World Geography Solutions Class - 10 Kips Cyber Beans Computer Code 165 Solutions
Class - 8 Veena Bhargava Geography Solutions Class - 11 CBSE Sumita Arora Python Solutions
Class - 8 Effective History & Civics Solutions Class - 12 CBSE Sumita Arora Python Solutions
Class - 8 APC Understanding Computers Solutions Class - 12 CBSE Preeti Arora Python Solutions
Class - 8 Kips Logix Computers Solutions Class - 12 NCERT Computer Science Solutions
Class - 9 Concise Physics Selina Solutions
Class - 9 Concise Chemistry Selina Solutions
Class - 9 Dalal Simplified ICSE Chemistry Solutions
Class - 9 Concise Biology Selina Solutions
Class - 9 Total Geography Morning Star Solutions
Class - 9 Veena Bhargava Geography Solutions
Class - 9 Total History & Civics Solutions
Class - 9 APC Understanding Computers Solutions
Class - 9 Kips Logix Computers Solutions
Class - 10 ML Aggarwal Mathematics Solutions
Class - 10 Concise Physics Selina Solutions
[Link] 16/17
5/20/24, 1:31 PM Chapter 4: Operators in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Class - 10 Concise Chemistry Selina Solutions
Class - 10 Dalal Simplified ICSE Chemistry Solutions
Class - 10 Concise Biology Selina Solutions
Class - 10 Total Geography Morning Star Solutions
Class - 10 Veena Bhargava Geography Solutions
Class - 10 Total History & Civics Solutions
Class - 10 APC Modern History & Civics Solutions
Class - 10 APC Understanding Computers Solutions
Class - 10 Sumita Arora ICSE Computers Solutions
Class - 10 Kips Logix Computers Solutions
Class - 11 APC Understanding Computers Solutions
Class - 12 APC Understanding Computers Solutions
ICSE/ISC SOLVED QUESTION PAPERS
ICSE Class 10 Computers Solved 10 Yrs Question Papers
Sample Papers ICSE Class 10 Computer Applications
ICSE Class 10 Physics Solved 10 Yrs Question Papers
Sample Papers ICSE Class 10 Physics
ICSE Class 10 Chemistry Solved 10 Yrs Question Papers
Sample Papers ICSE Class 10 Chemistry
ICSE Class 10 Biology Solved 10 Yrs Question Papers
Sample Papers ICSE Class 10 Biology
Class - 12 ISC Computer Science Solved Practical Papers
Class - 10 CBSE Computer Applications Solved Question Papers
Class - 10 CBSE Computer Applications Solved Sample Papers
Class - 10 CBSE Science Solved Question Papers
Class - 12 CBSE Computer Science Solved Question Papers
Copyright © KnowledgeBoat 2024
[Link] 17/17