You can use this assignment in your class!
Mastery Progress(100.0%)
i

Unit 1: Primitive Types - Review Assignment

Using Variables in Java

Write a program that declares and initializes two integer variables a and b with the values 10 and 20 respectively. Then, declare a third integer variable sum and assign it the sum of a and b.

You answeredJUST NOW
Java
public class Main {
public static void main(String[] args) {
// Declare and initialize the variables here
// Testing mechanism - do not modify!
System.out.println(sum);
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
You passed all test cases!
STDIN
Expected STDOUT
30
Your STDOUT
30

Did you like this question?

(Voting helps us personalize your learning experience!)
imgInstructor solution
Alec KretchAPR 21, 2024, 8:11:45 AM
Java
public class Main {
public static void main(String[] args) {
// Declare and initialize the variables here
int a = 10;
int b = 20;
int sum = a + b;
// Testing mechanism - do not modify!
System.out.println(sum);
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Was this helpful?

(Voting helps us personalize your learning experience!)
Think you've got it?

How do you use variables in an arithmetic operation in Java?

Select one of the following options:
  • A.

    By using the variable names in the arithmetic expression.

  • B.

    By using the variable names enclosed in quotes in the arithmetic expression.

  • C.

    By using the data types of the variables in the arithmetic expression.

  • D.

    By using the values of the variables in the arithmetic expression.

Submit answer

Was this helpful?

(Voting helps us personalize your learning experience!)

You may exit out of this review and return later without penalty.