What Is The Output Of The Following Java Codep Pre Langjava #478
What is the output of the following Java code?</p> <pre><code class="language-java"> class MinMax { public static void main(String[] args) { int a = 12; int b = 8; int c = Calc(a, b); System.out.println(c); } public static int Calc(int n1, int n2) { int min; if (n1 > n2) { min = n2; } else { min = n1; } return min; } }</code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs111 OOP Object Oriented Programming Java. It can also be found in gs gs111 Class Components (Using Java) - Member Functions - Quiz No.1.
What is the output of the following Java code?
class MinMax { public static void main(String[] args) { int a = 12; int b = 8; int c = Calc(a, b); System.out.println(c); } public static int Calc(int n1, int n2) { int min; if (n1 > n2) { min = n2; } else { min = n1; } return min; } }
12
8
Garbage Value
Compilation error