ProgrammingHardInfosys DSE · Wipro Elite
What is printed?
What is printed?
System.out.print('a' + 'b' + "c" + 'a' + 'b');- A. abcab
- B. 195cab
- C. 195c195
- D. cabcab
Correct answer: B. 195cab
'a' + 'b' is int addition (195); after the first String operand, + is left-associative concatenation of the char values.
More OOP with C++ and Java questions
- What is printed? java class K { int v; K(int v) { this.v = v; } public boolean equals(K o) { return o != null && v == o.v; } public int…
- What does new D().w() return? java interface A { default String w() { return "A"; } } interface B extends A { default String w() { return…
- What is printed? java class A { int a = f("a"); { f("i"); } A() { f("c"); } int f(String s) { System.out.print(s); return 1; } int b =…
- What is printed? java class A { static int x = init("Ax"); static int init(String s) { System.out.print(s); return 1; } } class B extends…
- What is printed? java List<Integer> l = new ArrayList<>(List.of(10, 20, 30, 1)); l.remove(1); l.remove(Integer.valueOf(1))…
- What is printed? java Object[] o = new String[1]; try { o[0] = 1; System.out.print("T"); } catch (ArrayStoreException e) {…