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:
The above program will generate syntax error because Char is not any built-in class or type in Java. Here, we need to use Character instead of Char.
Answer Question 2:
Output:
Explanation:
The above program will generate syntax error because decimal is not any built-in type in Java.
Answer Question 3:
Output:
Explanation:
In the above program, we created a class MainClass that contains a main() method, which is the entry point for the program. In the main() method we created three local variables A, B, and C initialized with 'A', 3, and 0 respectively.
Now evaluate the expression.
C = (byte)(A) *B-4; C = (byte)(’A’)*3-4; C = 65*3-4; C = 195-4; C = 191;
Here we typecast value of 'A' into byte, the ASCII value of 'A' is 65, and then finally print the value of variable C on the console screen.
Answer Question 4:
Output:
Explanation:
In the above program, we created a class Main that contains a main() method, which is the entry point for the program. In the main() method we created three local variables A, C, and val initialized with 'A', 0, and "123" respectively.
Now evaluate the expression,
C = (byte)(A) *Integer.parseInt(val)-4; C = 65 * 123-4; C = 7995-4; C = 7991;
Here, we typecast value of 'A' into byte, the ASCII value of 'A' is 65 and convert string "123" into integer number 123 using parseInt() method of Integer class and then finally print the value of variable C on the console screen.
Answer Question 5:
Output:
Explanation:
In the above program, we created a class Main that contains a main() method, which is the entry point for the program. In the main() method we created three local variables A, C, and val initialized with 'A', 0, and "123.34" respectively.
Now evaluate the expression,
C = (byte)(A) *Double.parseDouble(val)-4; C = 65 * 123.34-4; C = 8017-4; C = 8013.1;
Here, we typecast value of 'A' into byte, the ASCII value of 'A' is 65 and convert string "123.34" into double number 123.34 using parseDouble() method of Double class and then finally print the value of variable C on the console screen.
need an explanation for this answer? contact us directly to get an explanation for this answer