What will be the output of the following Java program? [code] class Output { public static void main(String args[]) {

What will be the output of the following Java program?
Code:
class Output 
{
        public static void main(String args[]) 
        {    
             int a,b,c,d;
             a=b=c=d=20
            a+=b-=c*=d/=20
           System.out.println(a+" "+b+" "+c+" "+d);
        } 
}
A. compile time error
B. runtime error
C. a=20 b=0 c=20 d=1
D. none of the mentioned
 
Answer: c
Explanation: Expression will evaluate from right to left.
output:
Code:
$ javac Output.java
$ java Output
20 0 20 1
This section of our 1000+ Java MCQs focuses on Bitwise operators of Java Programming Language.
 

Tìm kiếm

Back
Top