Q:
Java find output programs (Parameter Passing) | set 1
belongs to collection: Java find output programs
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 defined a static method swapValues() to swap two integer values, but we used '&' operator with arguments, we cannot use '&' operator with arguments in Java.
Answer Question 2:
Output:
Explanation:
The above program will generate syntax errors because we use pointers in the swapValues() method to swap argument values, but java does not support pointers.
Answer Question 3:
Output:
Explanation:
In the above program, we created a class ClsParameter that contains two data members val1 and val2 initialized with 10 and 20 respectively. Here, we also created a static method swapValues() that takes the object of ClsParameter as an argument. Here, we swapped the values of val1 and val2 with each other using the temporary variable temp.
Now look to the main() method, here we created the object C of ClsParameter class and pass object C into static method swapValues and then print swapped values val1 and val2 on the console screen.
Answer Question 4:
Output:
Explanation:
The above program will generate syntax errors because data members val1 and val2 are private members of Sample class but we accessed them from ClsParameter. But private members cannot be accessed outside the class.
Answer Question 5:
Output:
Explanation:
The above program will generate syntax error because we cannot create two public classes in a java program.
Answer Question 6:
Output:
Explanation:
In the above program, we created two classes Sample and ClsParameter. The Sample class contains two data members val1 and val2 and a static method swapValues() with the object of Sample class as an argument two swap values of data members val1 and val2 with each other.
Now look to the ClsParameter class. The ClsParameter class contains a main() method. In the main() method we created an object S of Sample class. Then we swapped values of val1 and val2 using static method swapValues() and then print swapped values on the console screen.
need an explanation for this answer? contact us directly to get an explanation for this answer