Quiz – JAVA Python JAVA AWS Git DevOps Menu Python JAVA AWS Git DevOps Leaderboard /5 Time is up!! Misc 1 / 5 What will be the output of below code: Copy Code Copied Use a different Browser class output { public static void main(String args[]) { String c = "Hello i love java"; boolean var; var = c.startsWith("hello"); System.out.println(var); } } a. 1 b. 0 c. True d. False Explanation: startsWith() method is case sensitive “hello” and “Hello” are treated differently, hence false is stored in var. 2 / 5 What will be the output of below code: Copy Code Copied Use a different Browser class increment { public static void main(String args[]) { int i = 5; System.out.print(++i * 4); } } a. 25 b. 20 c. 24 d. 21 Operator ++ has more preference than *, thus i becomes 6 and then gets multiplied by 8 gives 24. 3 / 5 What will be the output of below code: Copy Code Copied Use a different Browser class output { public static void main(String args[]) { StringBuffer s1 = new StringBuffer("Quiz"); StringBuffer s2 = s1.reverse(); System.out.println(s2); } } a. Quiz b. ziuQ c. QuizziuQ d. ziuQQuiz Explanation: reverse() method reverses all characters. It returns the reversed object on which it was called. 4 / 5 What will be the output of below code: Copy Code Copied Use a different Browser class String_demo { public static void main(String args[]) { char chars[] = {'a', 'b', 'c'}; String s = new String(chars); System.out.println(s); } } a. b b. c c. a d. abc Explanation: String(chars) is a constructor of class string, it initializes string s with the values stored in character array chars, therefore s contains “abc”. 5 / 5 What will be the error in the following Java code? Copy Code Copied Use a different Browser byte b = 50; b = b * 50; a. b cannot contain value 50 b. No error in this code c. b cannot contain value 100, limited by its range d. * operator has converted b * 50 into int, which can not be converted to byte without casting Explanation: While evaluating an expression containing int, bytes or shorts, the whole expression is converted to int then evaluated and the result is also of type int. Your score is The average score is 48% 0% Exit