Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
2.1k views
in Computer by (76.4k points)

Shalini is learning Java programming language, as it allows developers to write code that can run on any machine, regard less or architecture or platform. Help her in finding solutions of her problems :

(i) She wants to compare two integer values for equality in her java code. Out of (=) and (= =), which operator she should use and why?

(ii) Help her in writing Java code to initialize two integer variables named num1 and num2 with values 5 and 10 respectively. Increase the value of num 1 by 5 and decrease the value of num2 by 5.

1 Answer

+1 vote
by (75.2k points)
selected by
 
Best answer

(i) == operator

As = operator is assignment operator which will be used to assign the values to any variable/ constant white = = is comparison operator. It check for equality.

(ii) int num1 = 5, num2 = 10;

num1 = num1+ 5;

num2 = num2- 5;

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...