+ 2
Can I get the answer of;
public class Program { public static void main(String[] args) { int num1 = 4; int num2 = 8; num2 += num1; System.out.println(num2); } }
20 odpowiedzi
0
Ya only ints
+ 7
Satvik Jain
If you are asking this part that you don't understand I think it should be like that
Line 3 coverts num1, string to numerical by using int. If we don't covert 4 to numerical it will remain a string.
Same done in the below line.
In the third line you have added both the digits by + symbol.
In the last step you have used system.out.printin it is used for printing the results.
Hope this helps🤟
+ 7
This is simple problem addition of two numbers and your code is working fine and Output giving 12 . Don't post unnecessary questions you can also run on solo playground. If you have doubts in question then u can ask .
+ 6
Tibor Santa
Seems like my explanation is same. Isn't it. Do I have missed and part in it?
+ 6
Tibor Santa
If we don't use int method then do the num1=4 will be automatically be string?
Or do it will be changed according to the num?
+ 6
Satvik Jain
Escuse me?
I'm not fighting dude. I'm just clearing my doubt from Tibor sir.
Because I too have a confusion..(likely same)
+ 4
piyush there are no strings involved here. Both variables are declared as int.
+ 3
What is your question? Just run it in the code playground and see the result.
+ 3
Assign value 4 to variable num1
Assign value 8 to variable num2
Increment num2 by num1
this can be written as:
num2 = num2 + num1;
So num2 becomes 8+4=12
+ 3
int num1 = 4;
int is not a method, it is the type of the variable. We use int for numbers so that we can do math operations on them (like addition).
Inside the print statement, the number is automatically converted to String.
+ 3
Hey buddy,
Nobody can help but your study and learning can help you
And
asking questions which doesn't help everybody and doesn't allows you to learn anything again can be called a spam.
Try searching before asking questions.
And chatting in someone's post is also a spam guys.
+ 2
In python types are implicit.
... Switch now 🍻
+ 2
Try it on code playgroud...its better to you than posting here
+ 1
But I don't understand it
+ 1
Thanks guys 😃😃
+ 1
Please don't fight😭
+ 1
The answer is 12.
Why? :
Because num2+=num1 mean add num2 to num1
To be num2=num2+num1.
0
Ok thanks
0
Ok sorry 😖
0
No it needs system, vertual machine(VM), java compiler, java VM library as well as java runtime environment.
Be Cautious about this kind of questions...
DHANANJAY PATEL