1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
drek231 [11]
3 years ago
14

What is the output of the second println statement in the main method? public class Foo { int i; static int s; public static voi

d main(String[] args) { Foo f1 = new Foo(); System.out.println("f1.i is " + f1.i + " f1.s is " + f1.s); Foo f2 = new Foo(); System.out.println("f2.i is " + f2.i + " f2.s is " + f2.s); Foo f3 = new Foo(); System.out.println("f3.i is " + f3.i + " f3.s is " + f3.s); } public Foo() { i++; s++;
Computers and Technology
1 answer:
never [62]3 years ago
6 0

Answer:

The second print statement will print:

f2.i is 1 f2.s is 2

Explanation:

Initially when the execution start. i and s are both 0. i declared as a variable while s is a static variable which value stays once it is re-defined.

When f1 call i and s; their value is both 1 based on the increment statement in the constructor.

For the second print statement:

When f2 call i; it is re-initialized to 1. When f2 call s; it has initial value of 1 and is incremented to 2 which is printed. s hold the initial value of 1 because of the static keyword.

You might be interested in
Which job role requires you to create user guides for computer products and services?
kipiarov [429]

For plato I think technical writer is the answer.

Technical writer: As a technical writer, you’ll create user manuals and support guides for a number of computer products and services. You may also develop content to market technical products online.

4 0
3 years ago
Read 2 more answers
Greg works for online games development company. He occasionally visits online literature sites and downloads e-books of his cho
zalisa [80]

(A) Yes, because nobody is supposed to access non-work related sites during office hours.

3 0
3 years ago
Read 2 more answers
The ________ simulates your work area.
xz_007 [3.2K]
I believe it is, A. taskbar
5 0
3 years ago
PLEASE HELP!!!!!!!!!!!
Dafna1 [17]
I'd say Davis was trying to increase persuasive power. Given that he saw that nobody was really his friend because he was shy and quiet, he tried to persuade people to like him by going to the game and hanging out with people. 
4 0
3 years ago
Read 2 more answers
Insufficient vacuum will require the driver to _______________ to adequately activate the brakes?
sp2606 [1]
A i think idk im trying to earn points
8 0
3 years ago
Other questions:
  • Print either "Fruit", "Drink", or "Unknown" (followed by a newline) depending on the value of userItem. Print "Unknown" (followe
    15·1 answer
  • When the increment or decrement operator is placed before the operand (or to the operand's left), the operator is being used in
    6·1 answer
  • There are many different types of documents that are used to convey information in the business world-letters and
    12·1 answer
  • Stating a document is PDF or XPS document refers to document _______​
    10·1 answer
  • Which tool is used to view stars in galaxies far from the Milky Way?
    10·1 answer
  • A foreign exchange student brought his desktop computer from his home in Europe to the United States. He brought a power adapter
    9·1 answer
  • According to the government, employees have a right to understand the risks associated with the materials they work with.
    15·1 answer
  • What is the meaning of <br>computer<br>viruses ?​
    8·1 answer
  • )
    11·1 answer
  • 8.5 Edhesive Code Practice
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!