What is the printout of the third println statement in the main method? public class Foo { int i; static int s; public static void main(String[] args) { Foo f1 = new Foo(); System.out.println("fl.iis " + fl.i + " fl.sis " + fl.s); Foo f2 = new Foo(); System.out.println("f2iis" + f2i+"f2sis"+f2s); Foo f3 = new Foo(); System.out.println("f3.iis " + f3.i + "f3.sis" + f3.s); } public Foo() { i++; S++; } } f3.i is 1 f3.s is 1 f3.i is 1 f3.s is 2 f3.i is 1 f3.s is 3 f3.i is 3 f3.s is 1 f3.i is 3 f3.s is 3
Added by Robert G.
Close
Step 1
The third `println` statement is: ```java System.out.println("f3.iis " + f3.i + "f3.sis" + f3.s); ``` Show more…
Show all steps
Your feedback will help us improve your experience
Supreeta N and 93 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Evaluate the following code to determine the output: class Foo { public int i = 94; public Foo(int i) { this.i = i; } public static void main(String[] args) { Foo x = new Foo(51); Foo y = new Foo(73); y.i = x.i; y.i = 12; System.out.println(x.i); } }
Supreeta N.
Akash M.
Consider the following program: program main int x; proc A; int x; proc B; { x := 3; call C; x := x + 1; print x; } (end B) proc C; int x; { x := 1; call D; print x; call F; print x; } (end C) { x := 2; call B; x := x + 1; print x; } (end A) proc D; proc E; int x; { x := 5; call F; print x; } (end E) { x := x + 1; print x; call E; x := x + 1; print x; } (end D) proc F; { print x; x := x + 2; } (end F) { x := 1; call A; print x; } (end main)
Sri K.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD