Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

In Java, can we make functions inline like C++?(A) Yes(B) No

Answer»
2.

class intWrap {int x;}public class Main {public static void main(String[] args) {intWrap i = new intWrap();i.x = 10;intWrap j = new intWrap();j.x = 20;swap(i, j);System.out.println("i.x = " + i.x + ", j.x = " + j.x);}public static void swap(intWrap i, intWrap j) {int temp = i.x;i.x = j.x;j.x = temp;}}(A) i.x = 20, j.x = 10(B) i.x = 10, j.x = 20(C) i.x = 10, j.x = 10(D) i.x = 20, j.x = 20

Answer»
3.

class Test {public static void swap(Integer i, Integer j) {Integer temp = new Integer(i);i = j;j = temp;}public static void main(String[] args) {Integer i = new Integer(10);Integer j = new Integer(20);swap(i, j);System.out.println("i = " + i + ", j = " + j);}}(A) i = 10, j = 20(B) i = 20, j = 10(C) i = 10, j = 10(D) i = 20, j = 20

Answer»
4.

public class Main {public static void main(String args[]) {String x = null;giveMeAString(x);System.out.println(x);}static void giveMeAString(String y){y = "GeeksQuiz";}}(A) GeeksQuiz(B) null(C) Compiler Error(D) Exception

Answer»
5.

Output of following Java program?class Main {public static void main(String args[]) {System.out.println(fun());}int fun(){return 20;}}(A) 20(B) compiler error(C) 0(D) garbage value

Answer»