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
Simora [160]
4 years ago
15

What is the output of the second println statement in the main method?

Computers and Technology
1 answer:
Doss [256]4 years ago
3 0

Answer:

B. f2.i is 1 f2.s is 2

Explanation:

In Java there are two type of variables, first is static variables and second is instance variable. static variable class variable which means you can have only one variable for all instance of that class. But instance variable will only for instance/object of that class.

For this code example, i is and instance variable, for every instance of class Foo, there will be separate i variable. but s is a static variable and that will be associated with class.

So in this program the first instance incremented the s variable and changed its value to 1 as int's default value is 0 in the constructor. So for second instance, the s value changed to 2 that's why it prints f2.s as 2 and as we know i is instance variable and every instance of foo class have there own copy of i variable so it's value will remain same for every instance.

You might be interested in
Which of these purchases is most likely to be paid for with a credit card
Vesna [10]

Answer:

plane ticket?

Explanation:

7 0
3 years ago
Variables defined inside a member function of a class have: Block scope. Class or block scope, depending on whether the binary s
Snowcat [4.5K]

Answer:

The answer is "Block scope".

Explanation:

In the programming, the scope is a code, in which it provides the variable ability to exist and not be retrieved beyond variable. In this, the variables could be defined in 3 locations, that can be described as follows:

  • Inside a method or the block, which is also known as a local variable.
  • Outside of the method scope, which is also known as a global variable.
  • Defining parameters for functions known as formal parameters.
8 0
4 years ago
Which of the following defines a computer program?
andreev551 [17]

Answer:

A set of instruction given to computer

Explanation:

4 0
3 years ago
What process combines data from a list with the content of a document to provide personalized documentsWhat
Morgarella [4.7K]
Mail merge can combine data with the content of a document to make personalized documents.
6 0
3 years ago
Read 2 more answers
Discuss four uses of computer ​
PtichkaEL [24]

1. It helps to the development of our career.

2. Through the internet, we can know the facts which were happening all over the world

3. Computer can be use as a calculator too

4. We can store any kind of information.

<h3>Hope This Helps You ❤️</h3>
6 0
3 years ago
Read 2 more answers
Other questions:
  • What is the device called which typically combines the capabilities of a scanner, printer, fax, and copying machine?
    15·1 answer
  • Quien invento el primer vehiculo con motor?
    15·2 answers
  • 1. What runs horizontally and is identified with numbers?
    12·2 answers
  • Give your definition of a stored procedure. Based on the Academic Database, identify and describe a scenario where it would be n
    12·1 answer
  • Write a program that asks the user to enter the size of a triangle (an integer from 1 to 50). Display the triangle by writing li
    14·1 answer
  • The advantages of the dynamo
    15·1 answer
  • Why am I not getting the activation link for my account?
    11·1 answer
  • Selling R frog for 50 r-obux on r-oblox!!! dont answer if u not gonna buy it
    15·2 answers
  • Select all the correct answers.
    8·1 answer
  • A column does not consist of
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!