Java Tutorial 6 --- "Associativity and Precedence"
Java Tutorial 6 --- "Associativity and Precedence" DOC- CODE - package com.company ; public class Tut6 { public static void main (String[] args) { // Associativity & Precedence // int a = 6*5 - 34/2; /* BODMAS Rule doesn't apply in here = 6*5 - 34/2 = 30-34/2 = 30-17 = 13 */ // System.out.println(a); // int b = 34/2 - 6*5; /* Highest precedence goes to * and /. They are then evaluated on the basis of left to right associativity. = 34/2 - 6*5 = 17 - 6*5 = 17 - 30 = -13 */ // System.out.println(b); // Quick Quiz // (i) x-y/2 = ? int x = 50 ; int y = 10 ; int quiz1 = x-y/ 2 ; // JAVA = 45 BODMAS = 20 System. out .println(quiz1) ; // (ii) b^2-4ac/2 int a = 4 ; int b = 10 ; int c = 5 ; int quiz2...