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
Write an assembly language program with a loop and indexed addressing that calculates the sum of all the gaps between successive
PSYCHO15rus [73]

Answer:

Description: Write a MASM 32bit program with a loop and indexed addressing that calculates the sum of all thegaps between successive array elements. The array elements are doublewords, sequenced in nondecreasing order.

;Include Irvine32.inc file used with link library for 32 bit applications

.386

.model flat,stdcall

.stack 4096

ExitProcess proto,dwExitCode:dword

INCLUDE Irvine32.inc

.data

myArray DWORD 0,2,5,9,10

arrSize = ($-myArray)/TYPE myArray

gapArr DWORD arrSize-1 DUP(?)

sum DWORD ?

.code

main PROC

;Call the procedure

call Clrscr

;Initialize ESI pointer

mov esi, 0

mov ecx, arrSize

dec ecx

L1:

mov eax, myArray[esi+4]

sub eax, myArray[esi]

mov gapArr[esi], eax

inc esi

loop L1

;Calculate the sum of gaps between array elements

mov sum, 0

mov esi, 0

mov ecx, arrSize

dec ecx

;  move gapArr[esi] to a temporary register and then add that register value to sum

L2:

mov edx, gapArr[esi]  

add sum, edx

inc esi

loop L2

       INVOKE ExitProcess,0

main ENDP

END main

Explanation:

7 0
2 years ago
Assume that x is a double variable that has been initialized. Write a statement that prints it out, guaranteed to have a decimal
Feliz [49]

Answer:

cout <<showpoint << x; is  the statement which  prints the decimal point,        but without forcing scientific.

Explanation:

The showpoint function in c++ print the decimal point number without forcing scientific.The showpoint function set  the showpoint format flag for the str stream in c++.

Following are the program in c++

#include<iostream> //header file

using namespace std; // namespace

int main() // main function

{

   double x=90.67; // double variable

   cout <<showpoint << x; // display x  without forcing scientific

  return 0;

}

Output

90.6700

6 0
3 years ago
In this lesson you wrote code to make the turtle draw squares. Briefly describe how the code for
ale4655 [162]

Explanation:

that programming language you must use?

3 0
2 years ago
Production cost can be reduced using technology. Explain
Black_prince [1.1K]

Explanation:

By reducing the time the use on unnecessary tasks. And you would be able to operate on using your time on beneficial tasks

3 0
3 years ago
Can someone please help me? (,:
Scorpion4ik [409]
14) Answer: Feathered images

15) Answer: Scale

Hope this helps have a nice day :)
3 0
2 years ago
Other questions:
  • What were the first microblogs known as
    12·2 answers
  • Suppose you send data to the 11111111 11111111 11111111 11111111 ip address on an ipv4 network. to which device(s) are you trans
    15·1 answer
  • A video streaming website uses 32 bit integers to count the number of times each video is played. In anticipation of some videos
    14·2 answers
  • Which of these computers was marketed as a computer/game machine?
    15·2 answers
  • This type of peripheral is used to interact with, or send data to, the computer.
    12·2 answers
  • Which of the following is NOT an advantage to using inheritance?
    13·1 answer
  • For this scenario related to turtle drawing, indicate whether it is better to write a loop or a function (or a set of functions)
    13·1 answer
  • Gimme Shelter Roofers maintains a file of past customers, including a customer number, name, address, date of job, and price of
    8·1 answer
  • Pls say correct guyz pls pls pls
    7·1 answer
  • B. WAP to check whether input number is palindrome number or not using SUB...... END SUB.​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!