write an expression BNF grammar using the followin partial table of binary opera
ID: 3889267 • Letter: W
Question
write an expression BNF grammar using the followin partial table of binary operators in C:
= (assignment)
|| (logical or)
&& (logical and)
| (inclusive or)
^ (exclusive or)
& (and)
== != (equality)
< <= >= > (relational)
<< >> (shift)
+ - (additive)
* / % (multiplicative)
operators are in order of increasing precedence, that is, the assignment operator = has the lowest precedence and the multiplicative operators *, /, and % have the highest precedence. All operators on the same line have the same precedence and associativity. The assignment operator is right associative; all other operators are left associative.
Explanation / Answer
public class Test { public static void main(String args[]) { int a, b; a = 10; b = (a == 1) ? 20: 30; System.out.println( "Value of b is : " + b ); b = (a == 10) ? 20: 30; System.out.println( "Value of b is : " + b ); } } public class Test { public static void main(String args[]) { String name = "James"; // following will return true since name is type of String boolean result = name instanceof String; System.out.println( result ); } } class Vehicle {} public class Car extends Vehicle { public static void main(String args[]) { Vehicle a = new Car(); boolean result = a instanceof Car; System.out.println( result ); } }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.