What is the printout for the second statement in the main method? public class Foo { static int i = 0; static int j = 0; public static void main(String[] args) { int i = 2; int k = 3; { int j = 3; System.out.println("i + j is " + i + j); } k = i + j; System.out.println("k is " + k); System.out.println("j is " + j); } } k is 0 k is 1 k is 2 k is 3
Added by F-Tima O.
Close
Step 1
Step 1: The second statement in the main method is `int k = 3;`. Show more…
Show all steps
Your feedback will help us improve your experience
Supreeta N and 100 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.
Cora M.
What will be the output of the following statements? int i = 1, j; j = i-- - -2; printf("%d", j);
Madhur L.
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