Bit wise operators objective type questions and answers
(1)
public class BitwiseOpe {
public static void main(String[] args) {
int a=010;
Integer b=10;
double d=~a|(b=a)<<2+b;
System.out.print(d);
}
}
What will output when you compile and run the above code?
(a)32768.0
(b)-9.0
(c)1.0
(d)Compiler error
Answer: (b)
(2)
public class BitwiseOpe {
public static void main(String[] args) {
int a=010;
char c='a';
double d=-c%-2.D+(a^=2)-2;
System.out.print(d);
}
}
What will output when you compile and run the above code?
(a)-7.0
(b)-8.0
(c)-9.0
(d)Compiler error
Answer: (a)
(3)
public class BitwiseOpe {
public static void main(String[] args) {
int a=010;
char c='0';
double d=++a + 2.0^c;
System.out.print(d);
}
}
What will output when you compile and run the above code?
(a)61.0
(b)59.0
(c)59.000000
(d)Compiler error
Answer: (d)
(4)
public class BitwiseOpe {
public static void main(String[] args) {
int j=10;
j&=j|3;
System.out.print(j);
}
}
What will output when you compile and run the above code?
(a)11
(b)10
(c)true
(d)Compiler error
Answer: (b)
(5)
public class BitwiseOpe {
public static void main(String[] args) {
byte a=010,b=-12;
int c=a|b;
System.out.print(c);
}
}
What will output when you compile and run the above code?
(a)12
(b)-4
(c)-12
(d)Compiler error
Java questions of data types and answer
Java questions on if else statements
Java questions on switch case and answers
Java questions on looping and answers
Java questions on characters
Java questions on strings and answers
Java questions on variables and answers
Java questions on automatic type promotions
Java questions on bit wise operator
Java questions on operators and answers
Java questions on static keyword and answers
Java questions on super keyword and answers
Java questions on abstract class an answers
Java questions on interface and answers
Java questions on enum data type and answers
Java questions on break and continue keyword
Java questions of primitive data types
Java questions on conditional operators
Java questions on two dimensional array and answers
Java questions of data types and answer
Java questions on if else statements
Java questions on switch case and answers
Java questions on looping and answers
Java questions on characters
Java questions on strings and answers
Java questions on variables and answers
Java questions on automatic type promotions
Java questions on bit wise operator
Java questions on operators and answers
Java questions on static keyword and answers
Java questions on super keyword and answers
Java questions on abstract class an answers
Java questions on interface and answers
Java questions on enum data type and answers
Java questions on break and continue keyword
Java questions of primitive data types
Java questions on conditional operators
Java questions on two dimensional array and answers
No comments:
Post a Comment