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 1:
Output
Explanation
The above java program can be solved in following steps:
Step 1 –
A 2 dimensional array is initialized
Step 2 –
Nested for loop is used to print values of array.
Step 3 –
Print function is used to print the value, first value is arr[1][1]; as we can see that in this 2 dimensional array value of arr[1]={ 2,1 }; that’s why value of arr[1][1]=1;
Similarly values of arr[1][0]=2; arr[0][1]=3; and value of arr[0][0]=4;
Hence the resultant output of this program will be "1234".
Answer 2:
Output
Explanation
We can solve this problem in following steps:
Step 1 –
Object 1 and object 2 of class access is initialized.
Step 2 –
Value of x is initialized as 0 by calling it using object 1.
Step 3 –
Function increament() of class access is used by object 1. After this the value of static variable x is increased to 1.
Step 4 –
Function increament() of class access is used by object 2. After this the value of static variable x is increased to 2.
Step 5 –
Print function is used to print the sum of variable x accessed by object 1 and object 2.
As we know that variable x is a static variable hence its value for both object 1 and object 2 is same. Hence the values of x for both object 1 and object 2 is 2 so the output is 2+2=4.
Answer 3:
Output
Explanation
In this program the output is sum of ASCII values of h and i. The ASCII value of h is 104 and ASCII value of i is 105. The addition of 104 and 105 is 209. Hence the output is 209. This happens because in print function if we use arithmetic operations between the characters then print function performs the arithmetic operations between the ASCII values of given characters.
Answer 4:
Output
Explanation
Like C and C++, we cannot use 0 and 1 for checking condition in case of java. In java we have to use bool variable 'true' and 'false' to check conditions of the conditional operators.
The correct code should be:
Answer 5:
Output
Explanation
Like C and C++, we cannot call non static methods in a static method in java. To remove compilation error in this program we have to put static keyword before the function name. If we make the function static then this function can be call by main method in java.
The correct code should be:
need an explanation for this answer? contact us directly to get an explanation for this answer