Loading…
1. Variables and Operators in Java A variable is used to store data, and operators perform operations on these variables. Example: Arithmetic Operators public class BasicOperators { public static void main (String[] args) { int a = 10 , b = 5 ; System.out.println( "Sum: " + (a + b)); System.out.println( "Difference: " + (a - b)); System.out.println( "Product: " + (a * b)); System.out.println( "Quotient: " + (a / b)); System.out.println( "Remainder: " + (a % b)); } } Explanation: + (Addition), - (Subtraction), * (Multiplication), / (Division), % (Modulo) are used to perform arithmetic calculations. 2. Control Flow Statements in Java Control flow statements decide the execution path of the program based on conditions. Example: If-Else Statement public class IfElseExample { public static void main (String[] args) { int num = 10 ; ...