package shortcircuit;
import java.util.Scanner;
public class NewClass {
public boolean getTrue(){
System.out.println("Inside getTrue()");
return true;
}
public boolean getFalse(){
System.out.println("inside getFalse()");
return false;
}
public static void main(){
NewClass obj=new NewClass();
if(obj.getTrue()||obj.getFalse()){
System.out.println("T||F");
}
}
}
//
package shortcircuit;
public class ShortCircuit {
public boolean getTrue(){
System.out.println("Inside getTrue()");
return true;
}
public boolean getFalse(){
System.out.println("Inside getFalse()");
return false;
}
public static void main(String[] args) {
ShortCircuit obj=new ShortCircuit();
System.out.println("ShortCircuit:OR");
if(obj.getTrue()||obj.getTrue()){
System.out.println("T||T");
}
if(obj.getTrue()||obj.getFalse()){
System.out.println("T||F");
}
if(obj.getFalse()||obj.getTrue()){
System.out.println("F||T");
}
if(obj.getFalse()||obj.getFalse()){
System.out.println("F||F");
}
}
}
0 comments:
Post a Comment