Please help me to solve this | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

Please help me to solve this

public class Hello { public static void main(String[]args){ b = ++ b - a; a + = (b -a ); sum = a + b; System.out.println(sum); }} Use the above code to answer questions 8-10. 8.what is the value of b? 9.what is the value of a; 10. What is the value of sum?

7th Aug 2022, 5:12 PM
Mohammed Bukar
15 Answers
+ 4
What are your observations? Jumping into using variables before declaring it..? No values assinged? How the values come out?
7th Aug 2022, 5:17 PM
Jayakrishna 🇮🇳
+ 2
B = ++ b- a and A= (b- a Sum = a+ B Thank you
9th Aug 2022, 8:54 AM
Mugabi Joshua
Mugabi Joshua - avatar
+ 1
Mohammed Bukar have you tried running the code? You'll get an answer much quicker than waiting for the Sololearn Community to take your test for you.
7th Aug 2022, 5:40 PM
Brian
Brian - avatar
+ 1
System.out.println("a= " + a + " b= " + b) ; Add this to your code at end..
7th Aug 2022, 6:15 PM
Jayakrishna 🇮🇳
+ 1
Thank you all
7th Aug 2022, 8:44 PM
Mohammed Bukar
+ 1
You didn't take input from user Use scanner
9th Aug 2022, 5:11 AM
Yogesh Soni
Yogesh Soni - avatar
+ 1
Hi Bukar, what do you try to say? And what about your intention! Thanks 😊
9th Aug 2022, 8:41 AM
Athour Rahman
Athour Rahman - avatar
0
I'll be waiting for your answer.
7th Aug 2022, 5:13 PM
Mohammed Bukar
0
I'm sorry. It should be. static int a =1, b = 0, sum = 2;
7th Aug 2022, 5:19 PM
Mohammed Bukar
0
Mohammed Bukar Add that to your code and check output.. Then say your understandings.. and doubts here if any!!!!
7th Aug 2022, 5:46 PM
Jayakrishna 🇮🇳
0
I run it , but I want to see the value of a & b; Pls
7th Aug 2022, 6:06 PM
Mohammed Bukar
0
Put a and b into the println statement.
7th Aug 2022, 6:07 PM
Brian
Brian - avatar
0
And another question is : list and explain the three basis principles of OOP?
7th Aug 2022, 6:07 PM
Mohammed Bukar
7th Aug 2022, 6:10 PM
Brian
Brian - avatar
0
It's a wrong syntax bro A + = (b-a)
2nd Feb 2024, 12:04 AM
Mugabi Joshua
Mugabi Joshua - avatar