100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Test Bank For Building Java Programs A Back to Basics Approach 5th Edition By Stuart Reges, Marty Stepp (All Chapters, 100% Original Verified, A+ Grade) $28.49   Add to cart

Exam (elaborations)

Test Bank For Building Java Programs A Back to Basics Approach 5th Edition By Stuart Reges, Marty Stepp (All Chapters, 100% Original Verified, A+ Grade)

 17 views  0 purchase
  • Course
  • Building Java Programs A Back to Bas
  • Institution
  • Building Java Programs A Back To Bas

This Is The Original 5th Edition Of The Test Bank From The Original Author All Other Files In The Market Are Fake/Old Editions. Other Sellers Have Changed The Old Edition Number To The New But The Test Bank Is An Old Edition. Test Bank For Building Java Programs A Back to Basics Approach 5th Ed...

[Show more]

Preview 4 out of 370  pages

  • September 4, 2024
  • 370
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • Building Java Programs A Back to Bas
  • Building Java Programs A Back to Bas
avatar-seller
tutorsection
Building Java Programs A
Back to Basics Approach, 5e
Stuart Reges, Marty Stepp
(Test Bank All Chapters,
100% Original Verified, A+
Grade) Answers At The End
Of Each Chapter



Part 2: Final Exam: Page 2-207
Part 1: Midterm Exam : Page 208-370

, Part 2
Sample Final Exam #1
(Spring 2005; thanks to Stuart Reges)

1. Array Mystery
Consider the following method:

public static void arrayMystery(int[] a) {
for (int i = 1; i < a.length; i++) {
a[i] = i + a[i - 1] - a[i];
}
}

Indicate in the right-hand column what values would be stored in the array after the method arrayMystery executes
if the integer array in the left-hand column is passed as a parameter to it.



Original Contents of Array Final Contents of Array

int[] a1 = {7};
arrayMystery(a1); _____________________________

int[] a2 = {4, 3, 6};
arrayMystery(a2); _____________________________

int[] a3 = {7, 4, 8, 6, 2};
arrayMystery(a3); _____________________________

int[] a4 = {10, 2, 5, 10};
arrayMystery(a4); _____________________________

int[] a5 = {2, 4, -1, 6, -2, 8};
arrayMystery(a5); _____________________________




1 of 9

,2. Reference Semantics Mystery
The following program produces 4 lines of output. Write the output below, as it would appear on the console.

public class BasicPoint {
int x;
int y;

public BasicPoint() {
x = 2;
y = 2;
}
}

public class ReferenceMystery {
public static void main(String[] args) {
int a = 7;
int b = 9;
BasicPoint p1 = new BasicPoint();
BasicPoint p2 = new BasicPoint();

addToXTwice(a, p1);
System.out.println(a + " " + b + " " + p1.x + " " + p2.x);

addToXTwice(b, p2);
System.out.println(a + " " + b + " " + p1.x + " " + p2.x);
}

public static void addToXTwice(int a, BasicPoint p1) {
a = a + a;
p1.x = a;
System.out.println(a + " " + p1.x);
}
}




2 of 9

, 3. Inheritance Mystery
Assume that the following classes have been defined:

public class A extends B { public class C {
public void method2() { public String toString() {
System.out.print("a 2 "); return "c";
method1(); }
}
} public void method1() {
System.out.print("c 1 ");
public class B extends C { }
public String toString() {
return "b"; public void method2() {
} System.out.print("c 2 ");
}
public void method2() { }
System.out.print("b 2 ");
super.method2(); public class D extends B {
} public void method1() {
} System.out.print("d 1 ");
method2();
}
}

Given the classes above, what output is produced by the following code?

C[] elements = {new A(), new B(), new C(), new D()};
for (int i = 0; i < elements.length; i++) {
System.out.println(elements[i]);
elements[i].method1();
System.out.println();
elements[i].method2();
System.out.println();
System.out.println();
}




3 of 9

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 tutorsection. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

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

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

74735 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
$28.49
  • (0)
  Add to cart