1
AP CSA SEMESTER EXAM NEWEST
ACTUAL 2025/2026 WITH COMPLETE
QUESTIONS AND ANSWERS
VERIFIED/GRADED A+
Consider the following two code segments. Assume that the int variables m and n
have been properly declared and initialized and are both greater than 0.
I. for (int 1 = 0; i < m * n; i++)
{
System.out.print("A");
}
II. for (int j - 1; j <= m; j++)
{
for (int k = 1; k < n; k++
{
System.out.print("B");
}
}
Assume that the initial values of m and n are the same in code segment I as they
are in code II. Which of the following correctly compares the number of times
that "A" and "B" are printed when each code segment is executed?
, 2
A. "A" is printed m fewer times than "B"
B. "A" is printed n fewer times than "B"
C. "A" is printed m more times than "B"
D. "A" is printed n more times than "B" - (ANSWER)C. "A" is printed m more times
than "B"
Consider the following class
public class SomeMethods
{
public void one(int first)
{ / * implementation not shown * / }
publics void one(int first, int second)
{ / * implementation not shown * / }
public void one(int first, String second)
, 3
{ / * implementation not shown * / }
}
Which of the following methods can be added to the SomeMethods class without
causing a compile-time error.
I. public void one(int value)
{ / * implementation not shown * / }
II. public void one (String first, int second)
{ / * implementation not shown * / }
III. public void one (int first, int second, int third)
{ / * implementation not shown * / }
A. I only
B. I and II only
C. I and III only
D. II and III only - (ANSWER)D. II and III only
Consider the following code segment.
, 4
String str1 = new String("Advanced Placement");
String str2 = new String("Advanced Placement");
if (str1.equals(str2) && str1 ** str2)
{
System.out.println("A");
}
else if (str1.equals(str2) && str1 = str2
}
System.out.println("B");
}
else if (!str1.equals(str2) && str1 ** str2)
}
System.out.println("C");
}
else if (!str1.equals(str2) && str1 != str2)
}
System.out.println("D");
}
What, if anything, is printed when the code segment is executed?
A. A
AP CSA SEMESTER EXAM NEWEST
ACTUAL 2025/2026 WITH COMPLETE
QUESTIONS AND ANSWERS
VERIFIED/GRADED A+
Consider the following two code segments. Assume that the int variables m and n
have been properly declared and initialized and are both greater than 0.
I. for (int 1 = 0; i < m * n; i++)
{
System.out.print("A");
}
II. for (int j - 1; j <= m; j++)
{
for (int k = 1; k < n; k++
{
System.out.print("B");
}
}
Assume that the initial values of m and n are the same in code segment I as they
are in code II. Which of the following correctly compares the number of times
that "A" and "B" are printed when each code segment is executed?
, 2
A. "A" is printed m fewer times than "B"
B. "A" is printed n fewer times than "B"
C. "A" is printed m more times than "B"
D. "A" is printed n more times than "B" - (ANSWER)C. "A" is printed m more times
than "B"
Consider the following class
public class SomeMethods
{
public void one(int first)
{ / * implementation not shown * / }
publics void one(int first, int second)
{ / * implementation not shown * / }
public void one(int first, String second)
, 3
{ / * implementation not shown * / }
}
Which of the following methods can be added to the SomeMethods class without
causing a compile-time error.
I. public void one(int value)
{ / * implementation not shown * / }
II. public void one (String first, int second)
{ / * implementation not shown * / }
III. public void one (int first, int second, int third)
{ / * implementation not shown * / }
A. I only
B. I and II only
C. I and III only
D. II and III only - (ANSWER)D. II and III only
Consider the following code segment.
, 4
String str1 = new String("Advanced Placement");
String str2 = new String("Advanced Placement");
if (str1.equals(str2) && str1 ** str2)
{
System.out.println("A");
}
else if (str1.equals(str2) && str1 = str2
}
System.out.println("B");
}
else if (!str1.equals(str2) && str1 ** str2)
}
System.out.println("C");
}
else if (!str1.equals(str2) && str1 != str2)
}
System.out.println("D");
}
What, if anything, is printed when the code segment is executed?
A. A