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
A function checkZeros accepts three double parameters. It checks to see if the sum of all three parameters is equal to zero. If
blagie [28]

Answer:

Explanation:

The following code is written in Java. It creates the interface/prototype, the function, and the main method call. The function takes in the three int parameters, adds them, and then checks if the sum equals zero, outputting the correct boolean value. Output can be seen in the picture attached below. Due to technical difficulties I had to add the code as a txt file below.

6 0
2 years ago
Which one of the following pieces of information would be allowed as part of a limited data set?
Inessa05 [86]
Phone number would be allowed
6 0
3 years ago
The simple concept of personal computing, hatched by several Silicon Valley entrepreneurs and permeating almost all of modern so
rjkz [21]

Answer:

True

Explanation:

The advent of personal computing brought about by the implementation of several technologies including MOSFET, semiconductors, microchip and integrated circuits has revolutionized life in at a very high rate of change where traditional ways of doing things rapidly change and for the first time power was easily reachable by accessing a personal computer.

1. The computer personal computer brought about word processing, where there are very limited errors in individually printed documents and the time to produce a quality document was reduced

2. Email - With the advent of personal computers email, the information and communication time were lowered and it resulted in changes in commerce

3. Video conferencing - It was possible to have video conferencing with people and make decisions regarding direction can be made real time from very distant locations, which improved business reaction time

4. The mouse- The concept of having a graphic user interface improved computer interaction for people with limited programming skills.

7 0
3 years ago
C++
Nookie1986 [14]

Answer:

Following are the code to the given question:

#include <iostream>//header file

using namespace std;

class Window //defining a class Window

{

private:

int width, height;//defining integer variable

public:

friend ostream& operator << (ostream& stm, Window& width)//defining a friend function that takes two parameters

{

return stm<<"a ("<<width.width<<" x "<<width.height<<") window"; //use return keyword that return its values

}  

Window(int width, int height): width(width), height(height)//defining parameterized constructor that inherit width and height in its parameters  

{}

};

int main() //Main method

{

Window w(80,90);//calling class constructor

cout<<w;//print object value

return 0;

}

Output:

a (80 x 90) window

Explanation:

In the above code, a class "Window" is defined that uses a friend function "ostream& operator" is declared that uses the "ostrea&" as a data type to hold two-variable "stm and w" in its parameter, and declared the parameterized constructor to hold value by inheriting width and height in its parameters.

Inside the main method, a class object is created that calls the constructor and uses the print method to print object value.

7 0
3 years ago
Enumeration can be used to discover all but which of the following types of information?
Ostrovityanka [42]

Answer:A)Smart-card PINs

Explanation: A pin is the defines as the personal identification number that is allotted to the smart card uniquely that is no other smart can have same number.This number is only known by the smart card holder only.

This number is important because it works for the unlocking of the data that is securely stored and by entering the pin ,it can be decoded.Thus, the other given options are incorrect because they don't use enumeration to hide the data .Thus the correct option is option (A)

3 0
2 years ago
Other questions:
  • What daily life problems does the algorithm quicksort solve?
    14·1 answer
  • Which layer includes the physical transmission medium (cables or wireless media) that any network must use to send and receive t
    8·1 answer
  • What is qwerty and why is it on the keyboard?
    15·2 answers
  • Create an application for a library and name it FineForOverdueBooks. TheMain() method asks the user to input the number of books
    7·1 answer
  • Why would it be hard to find the ideal CO2 level if the light intensity were very low?
    9·1 answer
  • Create a text file named employee.dat containing the following data: b. Write a C++ program to read the employee.dat file create
    6·1 answer
  • The challenge of preparing for ____________________ is in ensuring that employees do not feel that they are being prepared for t
    7·1 answer
  • What is 4x+2x(-3-3) thanku
    11·2 answers
  • I WILL MARK IT BRAINLIEST FOR SURE ☺️❤️
    13·1 answer
  • DES is a commonly used symmetric encryption algorithm, developed in the mid-1990s by the American government in conjunction with
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!