logical Operators - Java | Practice | GeeksforGeeks

Logical operators are used when we want to check the truth value of certain statements. Logical operators help us in checking multiple statements together for their truthness.
Here we will learn logical operators like AND(&&), OR(||), NOT(!). These operators produce either a true or a false as an output.
Example 1:
Input:
true false

Output:
false true false


Explanation:

true&&false=>false

true||false=>true

!(true) && !(false)=>false
Example 2:
Input:
true true

Output:
true true false

Your Task:
Your task is to complete the function logicOp() which takes a and b as a parameter and prints (a AND b), (a OR b), (a NOT b) in separated by space.

Constraints:
a, b = {true, false}
0
knhashasPremium2 weeks ago
System.out.print((a&&b)+" "+(a || b)+" "+((!a)&&(!b)));
0
arpandutta5033 weeks ago
static void logicOp(boolean a,boolean b){        System.out.print(a&&b);     System.out.print(" ");     System.out.print(a || b);     System.out.print(" ");     System.out.print((!a)&&(!b));   }}
0
sharsimran20024 weeks ago
class Geeks{      static void logicOp(boolean a,boolean b){        System.out.print(a&&b);     System.out.print(" ");     System.out.print(a || b);     System.out.print(" ");     System.out.print((!a)&&(!b));   }}
0
shrutidhongade161 month ago
class Geeks{
    
    static void logicOp(boolean a, boolean b){
        /*output (a&&b), (a||b), and ((!a)&&(!b))separated by spaces*/
        
        System.out.printf("%s %s %s", a&&b, a||b, (!a && !b));
    }
}
0
badgujarsachin831 month ago
 static void logicOp(boolean a, boolean b){
        /*output (a&&b), (a||b), and ((!a)&&(!b))separated by spaces*/
        System.out.print((a&& b)+" ");
        System.out.print((a||b)+" ");
        System.out.print(!a && !b);
    }
-1
ravi119033852 months ago
System.out.print((a&&b)+" ");       System.out.print((a||b)+" ");       System.out.print(!a && !b);
-3
nagaajayk2 months ago
        System.out.print((a&&b)+" "+(a||b)+" "+(!a && !b));

-2
katwakrishna9502 months ago
class Geeks{
    
    static void logicOp(boolean a, boolean b){
        /*output (a&&b), (a||b), and ((!a)&&(!b))separated by spaces*/
        
        System.out.print( (a&&b)+" " );
        System.out.print( (a||b)+" " );
        System.out.print( ((!a)&&(!b)) );
        
    }
}
-1
hitentandon3 months ago
System.out.print((a&&b)+" "+(a||b)+" "+((!(a||b))));
-1
ritukapadiya20023 months ago
static void logicOp(boolean a, boolean b){       /*output (a&&b), (a||b), and ((!a)&&(!b))separated by spaces*/       System.out.print(a&&b);       System.out.print(" ");       System.out.print(a||b);       System.out.print(" ");       System.out.print((!a)&&(!b));          }
We strongly recommend solving this problem on your own before viewing its editorial. Do you still
                    want to view the editorial?
 Login to access your submissions. 

Problem


Contest

Reset the IDE using the second button on the top right corner.
Avoid using static/global variables in your code as your code is tested against multiple test cases and these tend to retain their previous values.
Passing the Sample/Custom Test cases does not guarantee the correctness of code. On submission, your code is tested against multiple test cases consisting of all possible corner cases and stress constraints.
You can access the hints to get an idea about what is expected of you as well as the final solution code.
You can view the solutions submitted by other users from the submission tab.