Java find output programs
- Java find output programs (Data Types) | set 1
- Java find output programs (Data Types) | set 2
- Java find output programs (Data Types) | set 3
- Java find output programs (Operators) | set 1
- Java find output programs (Operators) | set 2
- Java find output programs (Operators) | set 3
- Java find output programs (if else) | set 1
- Java find output programs (if else) | set 3
- Java find output programs (switch case) | set 1
- Java find output programs (switch case) | set 2
- Java find output programs (switch case) | set 3
- Java find output programs (Loops) | set 1
- Java find output programs (Loops) | set 2
- Java find output programs (Loops) | set 3
- Java find output programs (Arrays) | set 1
- Java find output programs (Arrays) | set 2
- Java find output programs (Arrays) | set 3
- Java find output programs (this Keyword) | set 1
- Java find output programs (final Keyword) | set 1
- Java find output programs (final Keyword) | set 2
- Java find output programs (static Keyword) | set 1
- Java find output programs (static Keyword) | set 2
- Java find output programs (Parameter Passing) | set 1
- Java find output programs (Class and Objects) | set 1
- Java find output programs (Class and Objects) | set 2
- Java find output programs (Class and Objects) | set 3
- Java find output programs (Constructor & Destructor) | set 1
- Java find output programs (Constructor & Destructor) | set 2
- Java find output programs (Constructor & Destructor) | set 3
- Java find output programs (Inheritance) | set 1
- Java find output programs (Inheritance) | set 2
- Java find output programs (Inheritance) | set 3
- Java find output programs (Interface) | set 1
- Java find output programs (Interface) | set 2
- Java find output programs (Interface) | set 3
- Java find output programs (Overloading) | set 1
- Java find output programs (Overloading) | set 2
- Java find output programs (Overriding) | set 1
- Java find output programs (Overriding) | set 2
- Java find output programs (Overriding) | set 3
- Java find output programs (Exception Handling) | set 1
- Java find output programs (Exception Handling) | set 2
- Java find output programs (Exception Handling) | set 3
- Java find output programs (Enumeration) | set 1
- Java find output programs (Enumeration) | set 2
- Java find output programs (Autoboxing & Unboxing) | set 1
- Java find output programs (Autoboxing & Unboxing) | set 2
- Find output programs (Java String class)
- Find Output of Java program - 1 (Mixed topics)
- Find Output of Java program - 2 (Mixed topics)
- Java find output programs (if else) | set 2
Answer Question 1:
Output:
Explanation:
In the above program, we created a class Main that contains the main() method. The main() method is the entry point of the program. Here, we created a constant A with initial value 4.23F and two local variables B and Z initialized with 3.23F and 2 respectively.
Let's evaluate the expression,
Z *= ++B+A%B;
Now, evaluate pre increment operator then value of B will be 4.23F,
Z *= B+A%B; Z *= 4.23+4.23%4.23; Z *= 4.23+0; Z = Z *4.23; Z = 2 *4.23; Z = 8.46;
Then the final value of Z will print on the console screen.
Answer Question 2:
Output:
Explanation:
The above program will generate syntax error because the relational operator returns Boolean values in java. Here, we used relation operator "==" to check equality.
Z = (A == B);
In the above expression, Z is an integer variable, and here we assigned a Boolean value to Z, then it will generate an error.
Answer Question 3:
Output:
Explanation:
The above program will generate syntax error, because conditional operator required LVALUE for assignment.
Answer Question 4:
Output:
Explanation:
In the above program, we created a class Main that contains the main() method. The main() method is the entry point of the program. Here, we created three variables A, B, and ret that are initialized with "3.14F", "3.14", and 0 respectively. Here, data type of A is float and data type of B is double then (A==B) condition will false and 0 assigned to variable ret. So finally '0' will print on the console screen.
Answer Question 5:
Output:
Explanation:
The above program will generate syntax error because in the below expression we used assignment operator "=" instead of "equal to" operator "==", that why 20 is assigned to the variable a, and we know that we cannot apply "&&" operator between 'int' and 'boolean' operands,
ret = (a=20)&&(3.14F==pi);
need an explanation for this answer? contact us directly to get an explanation for this answer