I found some tricks to solve java questions, when you are appearing for any kind of technical written test.I think it might help you too.Follow these tricks to get your test paper solved in less time.
- If you are asked to find value of a number after shifting right.Then just divide that number by 2 and discards the remainder.The qotient will be the answer.
5. Variables can have the same name as methods or class.
6. A constructor body can include a return statement providing no value is returned. 7. main can be declared as final.
8. You can not cast a boolean type to another primitive data type.
9. Java compiler will compile the classes that do not have contain a main() method but java interepreter
has no way to run those classes.
10. You do not have to have a default statement in a switch() block.
11. The default statement in switch() block can be appeared anywhere,does not have to be last.
12. All section of for loop are optional.
13. finalize() can execute only once on any object.
14. If any operand double in an expression then result is double.
15. If any operand is long in an expression then result will be promoted to long.
16. All bytes and shorts are promoted to int in an expression.
17. Conversion int to byte: syntax will be (byte)int var and the result will be remainder of any integer
divison by byte’s range i.e. 256
18. It is intersting to note that if you shift -1 right ,the result always remains -1.