© 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

16. What would you use to compare two String variables - the operator == or the method equals()?

Ans:
I'd use the method equals() to compare the values of the Strings and the == to check if two variables point at the same instance of a String object.

17. What is the difference between the prefix and postfix forms of the ++ operator?

Ans:
The prefix form performs the increment operation and returns the value of the increment operation. The postfix form returns the current value all of the expression and then performs the increment operation on that value.  

18. Given the byte with a value of 01110111, which of the following statements will produce 00111011?
[a] 0x77 << 1;
[b] 0x77 >>> 1;
[c] 0x77 >> 1;
[d] None of the above

Answer
[b] 0x77 >>> 1;

[c] 0x77 >> 1;

19. Which of the following is invalid?
[a] double d = 67567.89;
[b] long l = 56278;
[c] int j = (int) d;
[d] int i = new Integer(57);

Answer
[d] int i = new Integer(57);

20.Which of the following will compile without an error?
[a] char c = 'a';
[b] double d = 45.6;
[c] int i = d;
[d] int k = 8;

Answer
[a] char c = 'a';
[b] double d = 45.6;
[d] int k = 8;

21. The statement A %= 5, can best described as?
[a] A equals a divided by 5;
[b] A equals A in 5 digit percentage form
[c] A equals A modulus 5.
[d] None of the above

Answer

[c] A equals A modulus 5
Previous Next
1 2 3 4 5 6 7
SLogix Student Projects
bottom