Java Interview Questions
Q46. The operator sign ‘|’ is used for Bitwise ______
(a) AND
(b) OR
(c) XOR
(d) Complement
Answer: (b) OR
Q47. Which of the following operator has higher precedence
(a) +
(b) -
(c) *
(d) ||
Answer: (c) *
Q48. When a=9, b=12, c=3 then output of following statement is: x = a-b/3+c*2-1
(a) 8
(b) 10
(c) 12
(d) 15
Answer: (b) 10
Q49. Unary minus ‘-‘ has associativity from
(a) Right to left
(b) Left to right
(c) Not associative
(d) None of the above
Answer: (a) Right to left
Q50. Which one returns the smallest whole number greater than or equal to x is
(a) rint(x)
(b) sqrt(x)
(c) log(x)
(d) ceil(x)
Answer: (d) ceil(x)
Q51. What is the action of rint() in Java
(a) Returns the absolute value of the argument
(b) Returns the smallest of the two arguments
(c) Returns the double value that is closest in value to the argument
(d) Returns the largest integer that is less than or equal to the argument
Answer: (c) Returns the double value that is closest in value to the argument
Q52. Which one will returns the absolute value of a
(a) rint(a)
(b) log(a)
(c) abs(a)
(d) exp(a)
Answer: (c) abs(a)
Q53. One if or else if statement inside another if or else if statement is
(a) if statement
(b) if-else statement
(c) if-else-if ladder
(d) nested if statement
Answer: (d) nested if statement
Q54. Built-in multiway decision statement in Java is known as
(a) Switch
(b) Oprator
(c) Break
(d) Continue
Answer: (a) Switch
Q55. Case and break are used in ___
(a) Jump
(b) if-else
(c) nested-if
(d) Switch
Answer: (d) Switch
Q56. Which one jump statement is not supported in Java
(a) Else
(b) Break
(c) Return
(d) Continue
Answer: (a) Else
Q57. ____ leaves a loop, ____ jumps to the next iteration
(a) break,continue
(b) continue,break
(c) switch,break
(d) break,switch
Answer: (a) break,continue
Q58. In Java, the functions are called
(a) Fields
(b) Methods
(c) Operator
(d) Class
Answer: (b) Methods
Q59. Header should always be declared independently separated by
(a) Dot
(b) Slash
(c) Commas
(d) Pipe
Answer: (c) Commas
Q60. Which one enables an object to initialize itself when it is created
(a) Validator
(b) Arguments
(c) Parameters
(d) Constructor
Answer: (d) Constructor
Practice Test Exam