and All Correct Answers 2025-2026
Updated.
Consider the two methods (within the same class)
public static int foo(int a, String s)
{
s = "Yellow";
a=a+2;
return a;
}
public static void bar()
{
int a=3;
String s = "Blue";
a = foo(a,s);
System.out.println("a="+a+" s="+s);
}
public static void main(String args[])
{
bar();
}
What is printed on execution of these methods?
Select one:
a. none of the above.
b. a = 3 s = Yellow
c. a = 5 s = Yellow
d. a = 5 s = Blue
e. a = 3 s = Blue - Answer d
class Point {
int x,y;
Point (int x, int y) {
this.x = x;
,this.y = y;
}
public String toString() {
return "Point[" +x+ "," +y+ "]";
}
}
public class Main{
public static void main (String args[]) {
Point p = new Point (10,20);
System.out.println("p=" +p);}
}
What is the output of the following code? - Answer a
A process that involves recognizing and focusing on the important characteristics of a situation
or object is known as:
Select one:
a. Encapsulation
b. Object persistence.
c. Abstraction
d. Polymorphism
e. Inheritance - Answer c
Consider the following variable declarations:
int i;
float j;
boolean k;
Which of the following is correct initialization?
Select one:
a. i = 1; j = 1.0f; k = "true";
b. i = 1; j = 1.0; k = true;
c. i = 1; j = 1.0; k = "true";
d. i = 1; j = 1.0f; k = True;
e. i = 1; j = 1.0f; k = true; - Answer e
Which of these are legal identifiers.
, Select one:
a. All of the above.
b. number_1
c. $1234
d. number_a - Answer a
Analyze the following code.
public class Test {
public static void main(String[] args) {
System.out.println(max(1, 2));
}
public static double max(int num1, double num2) {
System.out.println("max(int, double) is invoked");
if (num1 > num2)
return num1;
else
return num2;
}
public static double max(double num1, int num2) {
System.out.println("max(double, int) is invoked");
if (num1 > num2)
return num1;
else
return num2;
}
}
Select one:
a. The program cannot compile because you cannot have the print statement in a non-void
method
b. The program cannot compile because the compiler cannot determine which max method
should be invoked
c. The program runs and prints "max(int, double) is invoked" followed by 2.
d. The program runs and prints 2 followed by "max(double, int)" is invoked
e. The program runs and prints 2 followed by "max(int, double)" is invoked - Answer b