1|Page
AP CSA Semester Exam Actual Complete Real Verified
Exam Questions And Correct Answers (Verified
Answers) Already Graded A+ | Newest Exam Version!!!
Consider the following code segment.
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)
,2|Page
}
System.out.println("D");
}
What, if anything, is printed when the code segment is
executed?
A. A
B. B
C. C
D. D
E. Nothing is Printed - Answer-B. B
Consider the following method that is intended to
determine fi the double values d1 and d2 are close
enough to be considered equal. For example, given a
tolerance of 0.001, the values 54. 32271 and 54.32294
would be considered equal.
/** @return true if d1 and d2 are within the specified
tolerance
* false otherwise
*/
,3|Page
public boolean almostEqual (double d1, double d2, double
tolerance)
{
/* missing code */
}
Which of the following should replace /* missing code */ so
that almost equal will work as intended?
A. return ( d1 - d2 ) <= tolerance
B. return (( d1 + d2 ) / 2 ) <= tolerance
C. return ( d1 - d2 ) >= tolerance
D. return (( d1 + d2 ) / 2 ) >= tolerance
E. return Math.abs( d1 - d2 ) <= tolerance - Answer-E.
return Math.abs( d1 - d2 ) <= tolerance
Consider the following method, biggest, which is intended
to return the greatest of three integer. It does not always
work as inteded.
public static int biggest(int a. int b, int c)
{
, 4|Page
if ( ( a > b ) && ( a > c ) )
{
return a;
}
else if ( ( b > a ) && ( b > c ) )
{
return b;
}
else
{
return c;
}
}
Which of the following best describes the error in the
method?
A. biggest always returns the value of A
B. biggest may not work correctly when c has the greatest
value
C. biggest may not work correctly when a and b has the
greatest value
AP CSA Semester Exam Actual Complete Real Verified
Exam Questions And Correct Answers (Verified
Answers) Already Graded A+ | Newest Exam Version!!!
Consider the following code segment.
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)
,2|Page
}
System.out.println("D");
}
What, if anything, is printed when the code segment is
executed?
A. A
B. B
C. C
D. D
E. Nothing is Printed - Answer-B. B
Consider the following method that is intended to
determine fi the double values d1 and d2 are close
enough to be considered equal. For example, given a
tolerance of 0.001, the values 54. 32271 and 54.32294
would be considered equal.
/** @return true if d1 and d2 are within the specified
tolerance
* false otherwise
*/
,3|Page
public boolean almostEqual (double d1, double d2, double
tolerance)
{
/* missing code */
}
Which of the following should replace /* missing code */ so
that almost equal will work as intended?
A. return ( d1 - d2 ) <= tolerance
B. return (( d1 + d2 ) / 2 ) <= tolerance
C. return ( d1 - d2 ) >= tolerance
D. return (( d1 + d2 ) / 2 ) >= tolerance
E. return Math.abs( d1 - d2 ) <= tolerance - Answer-E.
return Math.abs( d1 - d2 ) <= tolerance
Consider the following method, biggest, which is intended
to return the greatest of three integer. It does not always
work as inteded.
public static int biggest(int a. int b, int c)
{
, 4|Page
if ( ( a > b ) && ( a > c ) )
{
return a;
}
else if ( ( b > a ) && ( b > c ) )
{
return b;
}
else
{
return c;
}
}
Which of the following best describes the error in the
method?
A. biggest always returns the value of A
B. biggest may not work correctly when c has the greatest
value
C. biggest may not work correctly when a and b has the
greatest value