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
im past 1000 pts and it still hasnt up my rank from VIRTUOSO to EXPERT can someone explain and yes i have brainly plus
FromTheMoon [43]

Answer:

GREAT!

Explanation:

give me crown please

6 0
2 years ago
Read 2 more answers
Read carefully, is it a he or she?
Tasya [4]
I think there's a typo in the question, otherwise they probably meant a 'she', since the name is Maureen.

Also, the answer is Personal hygiene and grooming.
6 0
3 years ago
Read 2 more answers
I need ideas for a scratch (imagine, share, and program) coding project. You can think of any project you'd like thanks! :)
alex41 [277]

You did not include enough information.

5 0
3 years ago
Read 2 more answers
Calculate the average high and low in python code for beginners pls
Nikolay [14]

Answer:

There are two ways to find the average of a list of numbers in Python. You can divide the sum() by the len() of a list of numbers to find the average. Or, you can find the average of a list using the Python mean() function

Explanation:

3 0
3 years ago
What is the function of a header when writing HTML
marusya05 [52]
The Function of a header is that it makes your TEXT LOOK BIGGER

5 0
3 years ago
Other questions:
  • a computer that no longer works after having minor repair work done to it may have been damaged by ______.
    6·1 answer
  • Which Game Is Better & Favorite For You?
    12·2 answers
  • Which is the correct expansion of the term Internet? 
    9·2 answers
  • Just forgot where she saved a certain file on her computer therefore she searched for all files with jpg file extension which ty
    13·2 answers
  • What is hydraulic fracturing?
    7·1 answer
  • How often does colleges update the cost of attendance on their website?.
    13·1 answer
  • The area of a square is stored in a double variable named area. write an expression whose value is length of the diagonal of the
    8·1 answer
  • You can use a(n) to call a function in response to an event?
    14·1 answer
  • Question # 1 Multiple Select Which of the following shows the assignment of a string to a variable? Select 3 options. answer = "
    7·2 answers
  • Need answer ASAP!!!!
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!