100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
AP COMPUTER SCIENCE PRACTICE EXAM QUESTIONS |GUARANTEED PASS $12.99   Add to cart

Exam (elaborations)

AP COMPUTER SCIENCE PRACTICE EXAM QUESTIONS |GUARANTEED PASS

 5 views  0 purchase
  • Course
  • AP COMPUTER SCIENCE
  • Institution
  • AP COMPUTER SCIENCE

Consider the following method. public static int mystery(int[] arr) { int x = 0 for (int k = 0; k < h; k = k + 2) x = x + arr[k] return x; } Assume that the array nums has been declared and initialized as follows. int[] nums = {3, 6, 1, 0, 1, 4, 2}; (A) 5 (B) 6 (C) 7 (D) 10 ...

[Show more]

Preview 3 out of 22  pages

  • August 31, 2024
  • 22
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • AP COMPUTER SCIENCE
  • AP COMPUTER SCIENCE
avatar-seller
EXAMLINKS
AP COMPUTER SCIENCE PRACTICE
EXAM QUESTIONS |GUARANTEED
PASS

Consider the following method.


public static int mystery(int[] arr)
{
int x = 0
for (int k = 0; k < arr.length; k = k + 2)
x = x + arr[k]
return x;
}
Assume that the array nums has been declared and initialized as follows.
int[] nums = {3, 6, 1, 0, 1, 4, 2};


(A) 5
(B) 6
(C) 7
(D) 10
(E) 17 - ACCURATE ANSWERS✔✔ (C) 7


Consider the following partial class declaration.

,public class SomeClass
{
private int myA;
private int myB;
private int myC;
// Constructor(s) not shown
public int getA
{ return myA; }
public void setB(int value)
{ myB = value; }
The following declaration appears in another class.
SomeClass obj = new SomeClass();
Which of the following code segments will compile without error?
(A) int x = obj.getA();
(B) int x;
obj.getA(x);
(C) int x = obj.myA
(D) int x = SomeClass.getA();
(E) int x = getA(obj); - ACCURATE ANSWERS✔✔ (A) int x =
obj.getA


Which of the following changes to SomeClass will allow other classes to
access but not modify the value of myC ?

, (A) Make myC public.


(B) public int getC()
{ return myC; }


(C) private int getC()
{ return myC; }


(D) public void getC(int x)


(E) private void getC(int x)
{ x = myC; } - ACCURATE ANSWERS✔✔ (B) public int getC()
{ return myC; }


Consider the following code segment.
int x = 7;
int y = 3;


if ((x < 10) && (y < 0))
System.out.printIn("Value is: " + x * y);
else
System.out.printIn("Value is: " + x / y);
What is printed as a result of executing the code segment

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller EXAMLINKS. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $12.99. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

83637 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$12.99
  • (0)
  Add to cart