Yes, Each and every operator has an associativity.
The associativity (or fixity) of an operator is a property that determines how operators of the same precedence are grouped in the absence of parentheses. Operators may be left-associative, right-associative or non-associative.
Discuss About this Question.
Will the expression *p = p be disallowed by the compiler?
A:
Yes
B:
No
C:
D:
Answer:B
Because, here even though the value of p is accessed twice it is used to modify two different objects p and *p
Discuss About this Question.
Two different operators would always have different Associativity.
A:
Yes
B:
No
C:
D:
Answer:B
No, Two different operators may have same associativity.
Example:
Arithmetic operators like ++, -- having Right-to-Left associativity.
Relational operators like >, >= also have Left-to-Right associativity.
Discuss About this Question.
Are the following two statement same?
1.
a <= 20 ? (b = 30): (c = 30);
2.
(a <=20) ? b : (c = 30);
A:
Yes
B:
No
C:
D:
Answer:B
No, the expressions 1 and 2 are not same.
1. a <= 20 ? (b = 30) : (c = 30); This statement can be rewritten as,
if(a <= 20)
{
b = 30;
}
else
{
c = 30;
}
2. (a <=20) ? b : (c = 30); This statement can be rewritten as,
if(a <= 20)
{
//Nothing here
}
else
{
c = 30;
}
Discuss About this Question.
Associativity of an operator is either Left to Right or Right to Left.
A:
True
B:
False
C:
D:
Answer:A
Yes, the associativity of an operator is either Left to Right or Right to Left.
Discuss About this Question.
Ad Slot (Above Pagination)
Install ExamAdept
Fast access — add this app to your device.
To install on iPhone/iPad: tap Share → Add to Home Screen.
Discuss About this Question.