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]
3 years ago
15

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

Computers and Technology
1 answer:
Doss [256]3 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
Network services use to define a set of rules that govern how devices communicate and the data formats used in a network.
devlian [24]
The correct answer is protocols.
Protocols are rules and instructions as to how devices should function. Each of these devices has its own protocols about its inner workings that regulate how that particular device is going to work and function in real life. Without these protocols, the device wouldn't be able to work.
7 0
3 years ago
• Write a program that asks the user to enter a number of seconds. • If there are less than 60 seconds input, then the program s
serious [3.7K]

Answer:

The solution code is written in Python:

  1. sec = int(input("Enter number of seconds: "))
  2. if(sec >=60):
  3.    min = sec // 60
  4.    sec = sec % 60
  5. else:
  6.    min = 0
  7. print(str(min) + " minutes " + str(sec) + " seconds")

Explanation:

Firstly, use input function to prompt user to enter number of seconds and assign the input value to variable sec (Line 1).

Next, create an if statement to check if the sec is bigger or equal to 60 (Line 3). If so, we user // operator to get minutes and use % operator to get the seconds (Line 4 - 5).

Then we use print function to print the minutes and seconds (Line 9).

6 0
3 years ago
Read 2 more answers
Which of these domains is frequently researched based? A. .edu B. .com C. .org D. .gov
Mademuasel [1]
Is it where you can pick multiple answers

6 0
3 years ago
Read 2 more answers
Use the nutrition label to determine how many calories would be consumed by drinking 1 liter of Mountain Dew.
Rus_ich [418]
1 liter of mountain dew is 170 calories
4 0
3 years ago
Read 2 more answers
For any element in keysList with a value greater than 60, print the corresponding value in itemsList, followed by a semicolon (n
nika2105 [10]

Answer:

Below are the python Program for the above question:

Explanation:

keysList =[1,61,68,64]#key list items.

itemsList =[1,2,3,4]#item list items.

for x in range(len(keysList)):#for loop.

   if(keysList[x]>60):#check the value to be greator.

       print(itemsList[x],end=";")#print the value.

Output:

  • The above code will print as "2;3;4;".

Code Explanation:

  • The above code is in python language, in which the first and second line of the code defines a list. That list can be changed by the user when he wants.
  • Then there is a or loop that scans the keylist items and matches the items that it is greater than 60 or not. If it then takes the location and prints the itemlist by the help of that location.
6 0
3 years ago
Read 2 more answers
Other questions:
  • Is a display, or monitor, considered a piece of computer hardware
    15·1 answer
  • Daniela’s company has made the decision to allow employees to work from home as the company has outgrown their physical space. K
    13·1 answer
  • In file hashing, a file is read by a special algorithm that uses the value of the bits in the file to compute a single number ca
    13·1 answer
  • Given the following function definition
    13·1 answer
  • Students who respond promptly to e-mails are following which netiquette rule?
    13·2 answers
  • Which of the following is a collection of data organized in a manner that allows access, retrieval, and use of that data?
    10·1 answer
  • A form’s height is ______________________.<br><br> A property<br><br> A method<br><br> An event
    10·1 answer
  • Television, radio, newspapers, magazines, the Internet, and other forms of communication are collectively referred to as thea. W
    15·1 answer
  • What does "bbl" mean? my friend uses text slang all the time and i can never understand it unless it's lol.? please help!
    15·1 answer
  • Which of the following is not a storage medium?
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!