COURSES
MBAData Science & AnalyticsDoctorate Software & Tech AI | ML MarketingManagement
Professional Certificate Programme in HR Management and AnalyticsPost Graduate Certificate in Product ManagementExecutive Post Graduate Program in Healthcare ManagementExecutive PG Programme in Human Resource ManagementMBA in International Finance (integrated with ACCA, UK)Global Master Certificate in Integrated Supply Chain ManagementAdvanced General Management ProgramManagement EssentialsLeadership and Management in New Age BusinessProduct Management Online Certificate ProgramStrategic Human Resources Leadership Cornell Certificate ProgramHuman Resources Management Certificate Program for Indian ExecutivesGlobal Professional Certificate in Effective Leadership and ManagementCSM® Certification TrainingCSPO® Certification TrainingLeading SAFe® 5.1 Training (SAFe® Agilist Certification)SAFe® 5.1 POPM CertificationSAFe® 5.1 Scrum Master Certification (SSM)Implementing SAFe® 5.1 with SPC CertificationSAFe® 5 Release Train Engineer (RTE) CertificationPMP® Certification TrainingPRINCE2® Foundation and Practitioner Certification
Law
Job Linked
Bootcamps
Study Abroad
Master of Business Administration (90 ECTS)Master of Business Administration (60 ECTS)Master in Computer Science (120 ECTS)Master in International Management (120 ECTS)Bachelor of Business Administration (180 ECTS)B.Sc. Computer Science (180 ECTS)MS in Data AnalyticsMS in Project ManagementMS in Information TechnologyMasters Degree in Data Analytics and VisualizationMasters Degree in Artificial IntelligenceMBS in Entrepreneurship and MarketingMSc in Data AnalyticsMS in Data AnalyticsMaster of Science in AccountancyMS in Computer ScienceMaster of Science in Business AnalyticsMaster of Business Administration MS in Data ScienceMS in Information TechnologyMaster of Business AdministrationMS in Applied Data ScienceMaster of Business AdministrationMS in Data AnalyticsM.Sc. Data Science (60 ECTS)Master of Business AdministrationMS in Information Technology and Administrative Management MS in Computer Science Master of Business Administration MBA General Management-90 ECTSMSc International Business ManagementMS Data Science MBA Business Technologies MBA Leading Business Transformation Master of Business Administration MSc Business Intelligence and Data ScienceMS Data Analytics MS in Management Information SystemsMSc International Business and ManagementMS Engineering ManagementMS in Machine Learning EngineeringMS in Engineering ManagementMSc Data EngineeringMSc Artificial Intelligence EngineeringMPS in InformaticsMPS in Applied Machine IntelligenceMS in Project ManagementMPS in AnalyticsMS in Project ManagementMS in Organizational LeadershipMPS in Analytics - NEU CanadaMBA with specializationMPS in Informatics - NEU Canada Master in Business AdministrationMS in Digital Marketing and MediaMS in Project ManagementMaster in Logistics and Supply Chain ManagementMSc Sustainable Tourism and Event ManagementMSc in Circular Economy and Sustainable InnovationMSc in Impact Finance and Fintech ManagementMS Computer ScienceMS in Applied StatisticsMS in Computer Information SystemsMBA in Technology, Innovation and EntrepreneurshipMSc Data Science with Work PlacementMSc Global Business Management with Work Placement MBA with Work PlacementMS in Robotics and Autonomous SystemsMS in Civil EngineeringMS in Internet of ThingsMSc International Logistics and Supply Chain ManagementMBA- Business InformaticsMSc International ManagementMBA in Strategic Data Driven ManagementMaster of Business AdministrationMSc Digital MarketingMBA Business and MarketingMaster of Business AdministrationMSc Digital MarketingMSc in Sustainable Luxury and Creative IndustriesMSc in Sustainable Global Supply Chain ManagementMSc in International Corporate FinanceMSc Digital Business Analytics MSc in International HospitalityMSc Luxury and Innovation ManagementMaster of Business Administration-International Business ManagementMS in Computer EngineeringMS in Industrial and Systems EngineeringMSc International Business ManagementMaster in ManagementMSc MarketingMSc Business ManagementMSc Global Supply Chain ManagementMS in Information Systems and Technology with Business Intelligence and Analytics ConcentrationMSc Corporate FinanceMSc Data Analytics for BusinessMaster of Business AdministrationMaster of Business Administration 60 ECTSMaster of Business Administration 90 ECTSMaster of Business Administration 60 ECTSMaster of Business Administration 90 ECTSBachelors in International Management
For College Students

Logical Operators in Java

$$/$$

Let us now take a look at how these operations are represented in Java.

$$/$$

Video Transcript

 

So another use case for using logical operators with Booleans would be something like this. We can say that a person can get a loan only if his salary is greater than 50,000 and his credit score or his civil score is greater than 700 and that person is not blacklisted. So notice here I have used this small exclamation symbol. This exclamation symbol is what I called as the not operator in Java. So basically, whenever I say not of anything which is true, it gets converted into the opposite of whatever is the Boolean value. So I'll say that not of true is actually evaluated to false and not of false actually gets evaluated to true. So the not operator is useful in all those cases. Whenever I wish to reverse my any given Boolean value, not of true becomes false and not of false becomes true. So in this situation if I say not of blacklisted, that is I want that the person should not be blacklisted and only then the bank can give the loan to that person. Moreover, if the bank wants to ensure that all these three conditions should be true and only then the bank can give loan to that person, then we can use the and logical operator between these three conditions. So, when it comes to writing the code, the and operator is denoted by using the ampersand symbol twice like this. Similarly, here this and when written in the form of a code can be replaced by two ampersand symbols like this. So basically, my and operator can be denoted by using two ampersand symbols. Now imagine a case in which the bank would be willing to give loan to that person if any one of these conditions are true. That is if either the salary is greater than 50,000 or if the credit score is greater than 700, or if the person is not blacklisted. So, in situations wherein the bank needs to ensure that only one of the conditions being true is sufficient to give a loan, in that case we can use the or operator. So the or operator can be denoted by using two bars like this. You can find this symbol, the bar symbol near the enter key towards the right of your keyboard. So basically, when you wish to use the and operator you can input two ampersand symbols like this. And when you wish to use the or operator you can insert two bars like this. Moreover, the not symbol can simply be denoted as a single exclamation mark. Now imagine that I have three variables a, B and C. Suppose A is true and B is false. So what do you think will be the and operation between these two? So I say that the and between two different Booleans will be true only if both of them are true. Now in this case, since one of them is false, so the and of these two variables will actually evaluate to false similarly, if I wish to perform an or operation on these two variables, I say A or B. So the or operator gives true in all the cases except the case when both of them are false. If you want to remember it, simply just remember that the or of two different Boolean variables will become true if either one of them is true. In this case, a being true is a sufficient condition for A or B to evaluate to true. So the or between true and false is going to give me true. Imagine another case where C is equal to true and D is also equal to true. In this case, performing the or operation will give me what? Well, since both of them are true, and or just merely needs either one of them to be true. So the or operation between these two is going to give me true. And what will be the result of the and operation? We saw here? That and gives true only if all the conditions are met, that is, if all the boolean variables involved in the equation are true. So we say that the and between two true Boolean variables is going to give me true. So, just for your practice, can you tell me what will be the and and or of two Boolean variables in which both of them are false? So think about it and answer in the question that follows.

 

Video Recap

 

 

 Using logical operators with Booleans for loan eligibility

  • Loan eligibility criteria: salary > 50,000, credit/civil score > 700, not blacklisted

  • Exclamation symbol represents the not operator in Java

  • And operator denoted by two ampersand symbols in code

  • Or operator denoted by two bar symbols in code

  • And operator evaluates to true if both Booleans are true

  • Or operator evaluates to true if at least one Boolean is true

  • Practice question: and and or of two false Boolean variables

 

You’re now aware of a few situations where the boolean data type and logical operators can be used. You learnt about three logical operators here:

  1. AND (&&)

  2. OR (||, generally near the Enter key on your keyboard)

  3. NOT(!)

These operators help in condensing a condition into fewer lines; this simplifies your code.

 

Let us now see the different conditions in which these operations can be used and their results.

$$/$$

Now you are clear about how these operators work. But what if there are multiple “and” and “or” operations in one statement.  We will take a look at that in the next segment.