Share on Google+Share on Google+

SCJP Module-1 Question-21

The sample code given below will test your understanding about the simple Java logics of the program.

Given a sample code:

1    class Test {
2    public static void main(String[] args) {
3    int x = 4;
4    boolean bl1 = false;
5    boolean bl2 = true;

6    if ((x == 3) && !bl2)
7    System.out.print("hello");
8    System.out.print("hi");

9    if ((bl2 = true) && bl1)
10 System.out.print("bye");

What will be the result? Choose the correct option?

(A) hello
(B) hi
(C) bye
(D) Compilation error at line no 9.




Posted on: July 21, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.


Advertisement null