What do you understand by increment and decrement operators?
Increment and decrement operators are unary operators that add or
subtract one, to or from their operand, respectively. They are commonly implemented in imperative programming languages. The increment operator increases, and the decrement operator decreases, the value of its operand by 1. Ex: c++, z-- What is the main difference between Prefix and Postfix Operators? The prefix operator ++ adds one to its operand / variable and returns the value before it is assigned to the variable. In other words, the increment takes place first and the assignment next. The postfix operator ++ adds one to its operand / variable and returns the value only after it is assigned to the variable. Ex: int a=5,b=10; System.out.print(a++); System.out.println(++b); What are Shorthand Operators in Java? Java provides some special Compound Assignment Operators, also known as Shorthand Assignment Operators. It's called shorthand because it provides a short way to assign an expression to a variable. This operator can be used to connect Arithmetic operator with an Assignment operator. Ex: int s=0; s+=5; What is Expressions in Java? Ans: An expression in Java is any valid combination of operators, constants, variables and method invocations, which are constructed according to the syntax of the language, that evaluates to a single value. Ex: int z=a+b; What are statements in Java? Java statements are instructions that tell the programming language what to do, like declaration and string statements. Basic statements define variables and initiate Java methods or start the execution of blocks of other statements. Assignment statements assign values to variables. Ex: a=100; //assignment statement C++;// increment statement System.out.println(“St. Xavier’s School”);// method invocation statement Bank ramu=new Bank(); //object creation statement
What is a block in Java?
A block in Java is a group of one or more statements enclosed in braces. A block begins with an opening brace ({) and ends with a closing brace (}). Between the opening and closing braces, you can code one or more statements. Ex: for(int i=1;i<=5;i++) { System.out.println(i); } What is new operator in Java? The ‘new’ operator in Java is responsible for creation new object or instance of a class. It dynamically allocates memory which means that the memory is allocated at the run time of the program. Ex: Bank ob=new Bank(); What is dot operator in Java? The dot operator, also known as separator or period used to separate a variable or method from a reference variable. Only static variables or methods can be accessed using class name. Code that is outside the object's class must use an object reference or expression, followed by the dot (.) Ex: Bank ob=new Bank(); ob.Simp(); What is the difference between System.out.print() and System.out.println()? The only difference between println() and print() method is that println() throws the cursor to the next line after printing the desired result whereas print() method keeps the cursor on the same line. Attempt the following: 1)With the help of program explain the difference between System.out.print() and System.out.println()? 2) With the help of a program explain logical operators?