enthuware.ocajp.i.v7.-2-.1065

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
ashishrai.kv
Posts: 33
Joined: Tue Jan 09, 2018 2:12 am
Contact:

enthuware.ocajp.i.v7.-2-.1065

Post by ashishrai.kv »

Code: Select all

class LoopTest{
	
       
    public static void main(String[] args) {

   boolean flag = true;
   if(flag == false){
      System.out.println("1");
   }else if(!flag&flag){//line 2
      System.out.println("2");
   }else if(!flag){
      System.out.println("3");
   }else    System.out.println("4");}}

on above question when i change the elseif in //line2, i am getting output as 4.

can you give me a reference or examples of which operator &&,& ?,||,^. gives what output, in book its quite confusing?

admin
Site Admin
Posts: 10046
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: enthuware.ocajp.i.v7.2.1065

Post by admin »

You are asking a very broad question that cannot be answered in a post. You may start with this: https://stackoverflow.com/questions/719 ... nd-in-java
If you like our products and services, please help us by posting your review here.

ashishrai.kv
Posts: 33
Joined: Tue Jan 09, 2018 2:12 am
Contact:

Re: enthuware.ocajp.i.v7.-2-.1065

Post by ashishrai.kv »

ok thanks for the link, will look into it

but can you help me with whats happening in //line2

admin
Site Admin
Posts: 10046
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: enthuware.ocajp.i.v7.-2-.1065

Post by admin »

Well, the value of flag is true, so !flag&flag will be !true & true => false & true => false
If you like our products and services, please help us by posting your review here.

ashishrai.kv
Posts: 33
Joined: Tue Jan 09, 2018 2:12 am
Contact:

Re: enthuware.ocajp.i.v7.-2-.1065

Post by ashishrai.kv »

Thanks,

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 54 guests