What is displayed by the following program? : Questions « Operators « SCJP

Home
SCJP
1.Java Source And Data Type
2.Operators
3.Modifiers
4.Type Casting
5.Statements
6.Object Oriented
7.Thread
8.Utility Classes
9.File
SCJP » Operators » Questions 
2.14.23.What is displayed by the following program?
public class MainClass {
  static boolean ShortCut(boolean b) {
    System.out.print(" ShortCut ");
    return b;
  }

  public static void main(String[] args) {
    boolean b1 = true;
    boolean b2 = false;
    if (b2 & ShortCut(b1))
      System.out.println(1);
    else if (b1 | ShortCut(b2))
      System.out.println(2);
  }
}
2.14.Questions
2.14.1.What results from running the following code?
2.14.2.Answer: byte binary calculation
2.14.3.What results from attempting to compile and run the following code?
2.14.4.Answer: compile
2.14.5.What does the following code do? (if (i != null & i.intValue() == 5))
2.14.6.Answer: & and condition statements
2.14.7.What is the value of 111 % 13?
2.14.8.Answer: value of 111 % 13
2.14.9.What is the value of 9 + 8 % 7 + 6?
2.14.10.Answer: value of 9 + 8 % 7 + 6
2.14.11.What is the value of y outputing from System.out.println()?
2.14.12.Answer: post-increment
2.14.13.What is the value returned by "abcd" instanceof Object?
2.14.14.Answer: "abcd" instanceof Object
2.14.15.What is the value of 8 | 9 & 10 ^ 11?
2.14.16.Answer: 8 | 9 & 10 ^ 11
2.14.17.What is the output(n & n + 1 | n + 2 ^ n + 3)?
2.14.18.Answer: n & n + 1 | n + 2 ^ n + 3
2.14.19.What is the value of -31 >>> 5 >> 5?
2.14.20.Answer: -31 >>> 5 >> 5
2.14.21.What is the value displayed?
2.14.22.Answer: (b1 | b2 & b3 ^ b4)
2.14.23.What is displayed by the following program?
2.14.24.Answer: & vs &&
2.14.25.What is the output displayed?
2.14.26.Answer: String concatenation and assignment
2.14.27.Which is the output from the following program?
2.14.28.Answer: byte and double casting
2.14.29.What is the result of the expression 5.4 + "3.2"?
2.14.30.Answer: 5.4 + "3.2"
2.14.31.What is the result of the following program?
2.14.32.Answer: (i | j) % (i & j)
2.14.33.Based on the following code which of the following are true?
2.14.34.Answer: instanceof and class hierarchy
2.14.35.A reference to an array can be cast to a reference to an Object(True/False).
2.14.36.Answer: array object casting
2.14.37.A reference to an array can be cast to a reference to a Cloneable(True/False).
2.14.38.Answer: array object and Cloneable
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.