Operators in Java -2

8) Is &&= a valid operator?

Ans : No.


9) Can a double value be cast to a byte?

Ans : Yes

10) Can a byte object be cast to a double value ?

Ans : No. An object cannot be cast to a primitive value.

11) What are order of precedence and associativity?

Ans : Order of precedence the order in which operators are evaluated in expressions.

Associativity determines whether an expression is evaluated left-right or right-left.


12) Which Java operator is right associativity?

Ans : = operator.

13) What is the difference between prefix and postfix of — and ++ operators?

Ans : The prefix form returns the increment or decrement operation and returns the value of the increment or decrement operation.

The postfix form returns the current value of all of the expression and then

performs the increment or decrement operation on that value.


14) What is the result of expression 5.45 + “3,2”?

The double value 8.6

The string “”8.6”

The long value 8.

The String “5.453.2”

Ans : d


15) What are the values of x and y ?

x = 5; y = ++x;

Ans : x = 6; y = 6

16) What are the values of x and z?

x = 5; z = x++;

Ans : x = 6; z = 5

Ref Link contributor : http://www.hudihudi.com/placement/java/java12.htm

Permanent link to Java Tutorials / Java Interview Questions: http://www.freshersinterviewquestions.com/java-interview-questions/