Question :-
1.Write down the steps to write a program to assign three numbers calculate their sum in Java?
2.Give 3 examples of valid identifiers in Java.
3.Write a note on operators in Java explain each nicely with suitable examples.
☆ Request :-
• Kindly Don't spam
• No copied answer
Answers
Answer:
Answer 1
import java.util.Scanner;
// Java-W3schools
public class SumThreeNumbers {
public static void main(String[] args) {
int number1;
int number2;
int number3;
Scanner scanner = new Scanner(System.in);
System.out.println("Enter numner 1 : ");
number1 = scanner.nextInt();
System.out.println("Enter numner 2 : ");
number2 = scanner.nextInt();
System.out.println("Enter numner 3 : ");
number3 = scanner.nextInt();
int finalResult = number1 + number2 + number3;
System.out.println("Final resut of sum of given three numbers is " + finalResult);
}
}
Answer 2
Test : class name.
main : method name.
String : predefined class name.
args : variable name.
a : variable name.
Answer 3
Operators constitute the basic building block to any programming language. Java too provides many types of operators which can be used according to the need to perform various calculation and functions be it logical, arithmetic, relational etc. They are classified based on the functionality they provide. Here are a few types:
Arithmetic Operators
Unary Operators
Assignment Operator
Relational Operators
Logical Operators
Ternary Operator
Bitwise Operators
Shift Operators