© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu

Home Placements Interview Questions Java Interview Questions And Answers Java Interview Questions On Operators ▼

Java Interview Questions On Operators

5. Explain About Boolean in Java?

Ans:

In Java for each primitive type has a corresponding wrapper class. A wrapper class is nothing but a class that encapsulates a single immutable value.

boolean b = true;
Boolean wrapperB = new Boolean(b);
Example:
Boolean wrapperB = new Boolean("true");

Note: All the wrapper classes throw "NumberFormatException" except boolean. The Boolean wrappers can be constructed from Strings also as mentioned above.

6. What are the bitwise operator available in java?

Ans:

These are bitwise operators provide AND, OR, XOR operations only for integral types.

  • l For AND operations 1 and 1 gives you 1, any other combination is zero.
  • l For OR operations 0 and 0 gives you 0, any other combination is 1.
  • l For XOR operations 0 and 1 or 1 and 0 gives you 1 , any other combination is 0.

7. Can bitwise operators used in Boolean operations?

Ans:

The Bitwise operators can also be used in Boolean operations. If applied to booleans it uses true or false which are equivalent to 1 and 0.

8. Define short circuit operators?

Ans:

The short circuit operators && and || provide logical AND and OR operations on boolean types.
The main difference between & and && and between | and || is that the right hand side operand may not be evaluated.

Look at the following examples.

  • l In an AND operation if the first operand is false then the result is definitely false.
  • l In an OR operation if the first operand is true then the result is definitely true.
Previous Next
1 2 3 4 5 6 7
SLogix Student Projects
bottom