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
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 AnalyticsMS 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 Administration | STEMMS 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 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 MediaMSc Sustainable Tourism and Event ManagementMSc in Circular Economy and Sustainable InnovationMSc in Impact Finance and Fintech ManagementMS Computer ScienceMS in Applied StatisticsMaster 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 ManagementMSc Digital MarketingMBA Business and MarketingMaster of Business AdministrationMSc in Sustainable Global Supply Chain ManagementMSc 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 AdministrationMaster of Business AdministrationMSc in International FinanceMSc in International Management and Global LeadershipMaster of Business AdministrationBachelor of BusinessMaster of Business Administration 60 ECTSMaster of Business Administration 90 ECTSMaster of Business Administration 90 ECTSBachelor of Business AnalyticsBachelor of Information TechnologyMaster of Business AdministrationMBA Business AnalyticsMSc in Marketing Analytics and Data IntelligenceMS Biotechnology Management and EntrepreneurshipMSc in Luxury and Fashion ManagementMaster of Business Administration (90 ECTS)Bachelor of Business Administration (180 ECTS)B.Sc. Computer Science (180 ECTS) MSc in International Corporate Finance MSc in Sustainable Luxury and Creative IndustriesMSc Digital Marketing
For College Students

Precendence Order of Logical Operators

$$/$$

Just like arithmetic operations follow the BODMAS rule, similarly, there is a predefined precedence order in which a statement with logical operators is evaluated.

Let us try to understand the precedence order through the following video:

$$/$$

Video Transcript

 

So now consider a case where you have three booleans like this boolean a is true, B is false and C is true. Now in the case where you are trying to evaluate an expression like this that is A or B and not of C, then what do you think will be the result of this operation? So type this in your file and try to run it and see what output do you get on the browser console. Then write that output in the question that follows. So now if you try to evaluate this expression simply from left to right what you will see is that A or with B that is true or with false. So this is going to give me true. Now if I do true and of not C. So here not of C is actually false since C is true. So then if I do true and with false so the and between two values such that if either one of them is false gives me false. So on evaluating the expression simply from left to right gives me the value false. But you might have noticed that when you run the same expression then the result on the console actually gives you value true.

 

So this means that the expressions like these are not actually evaluated from left to right and they follow a precedence order between these different logical operators. So this precedence order actually tells you that first all the not logical operators will be resolved, then comes the and operator and lastly comes the or operator. So in any given expression first not symbol will be evaluated, then the expression with the and symbol will be evaluated and lastly the expression with the or symbol will be evaluated. So based on this precedence order can we now evaluate this expression? So basically we had A or B and not of C. So according to this not is the first in the precedence order. So first not of C will be evaluated, not of C will give me false. Then the and operator comes. So we say B and with false what is B here? B here is false so it gives me false here and when I try to do the and between two false values it gives me a result false. Then in the last step I will do a or with this false value what is A here? A here is true. So the or operation between a true value and a false value gives me true. So basically a here is true and when I do true or with false it gives me the result true. So now you have concluded how this true came out to be printed on your console. Now suppose you encounter a situation where you write a statement like this but you don't want the and operator to be evaluated before the or operator. Then if you want a certain expression to be evaluated first, then you can simply enclose it within the brackets. As an example, suppose you had something like this so according to this not will be evaluated first then and then or but suppose you want that or should be evaluated before and then you can simply enclose this expression within the brackets. So then what will happen is that this or operation will be evaluated before that and operation. So this is what is the precedence order between these logical operators.

 

Video Recap

 

  • Logical operators and their precedence order explained

  • Example with boolean values of A, B, and C

  • Explanation of left-to-right evaluation of expression

  • Not operator evaluated first, then and operator, and lastly or operator

  • Explanation of how to use parentheses to alter evaluation order

  • Importance of understanding logical operator precedence for correct evaluation of expressions

 

As you learned, this is the precedence order in which the logical operations are evaluated:

  1. NOT

  2. AND

  3. OR

If you want an expression to be evaluated first, then you need to enclose it within brackets.

$$/$$

Let us now try to code all this on the IntelliJ console.

You can download the following java file which will be very useful to you while watching the video. Right click on the java file and open it with Intellij. Please be careful with the name of the java file. The name of the java file should exactly be same as the class name inside it for the code to run. So make changes accordingly.

$$/$$

Since you have now learned to write a lot of code, in the following segments, you will be introduced to some of the best practices to be followed while coding.