How many employee objects exist in the heap

Assignment Help JAVA Programming
Reference no: EM13939976

public class Syntax2
{
private int x, n;

public Syntax2(int a, int b)
{
x = a;
n = b;
}

public int sumofsquares(int x, int y)
{
return x * x + y * y;
}

public int nTimesProduct(int x, int y)
{
return n * x * y;
}

//test program
public static void main(String[] args)
{
Keyboard kbd = new Keyboard();
System.out.println("Enter two numbers ");
int m = kbd.readInt();
int n = kbd.readInt();
System.out.println("The result is: " + sumofsquares(m, n));
System.out.println("The other result is: " + nTimesProduct(m, n));
}

}

The above code has the following two errors:

Syntax2.java:39: non-static method sumofsquares(int,int) cannot be referenced from a static context: System.out.println("The result is: " + sumofsquares(m, n));

Syntax2.java:40: non-static method nTimesProduct(int,int) cannot be referenced from a static context: System.out.println("The other result is:" + nTimesProduct(m, n));

How do you rewrite this code so that it compiles and runs correctly, without making the sumofsquares and nTimesProduct methods static.

-----------------------------

Assume you have a class called Employee whose constructor takes two arguments: the employee's name and id number. Consider the following code fragment:

Employee [ ] ea = new Employee[20];
Employee emp1 = new Employee("Bob Jones", 34532);
Employee emp2 = emp1;
ea[0] = emp1;
ea[1] = emp2;

How many Employee objects exist in the heap in the above code? _______

What is the total number of all objects in the heap in the above code? _______

Reference no: EM13939976

Questions Cloud

Manufacture and retail own-branded barbecues and products : The first opportunity is to manufacture and retail own-branded barbecues and products. Manufacture would take place at a leased plant in India as BBQfun has no manufacturing capability. Also, manufacture in Australia would be too expensive.
Rewrittting codes in java : However, I am told the above code would not be written by an experienced Java programmer because the showMessageDialog method is static within the class. How would a pro would write it?
Application of revenue management in hospitality industry : In the past few years there has been a rapid development in the application of revenue management in the hospitality industry, and this can be supported by the volume of material published in this area.
Interactive natural cubic spline : My project depends on previous homework because of that I posted all the questions to be clear, but the main project that I need help with is the homework3
How many employee objects exist in the heap : Assume you have a class called Employee whose constructor takes two arguments: the employee's name and id number
Prepare a statement of cost of goods manufactured for april : Prepare a statement of cost of goods manufactured for April. Assume that the begin- ning balance in the raw materials account was $1,400 and that the beginning bal- ance in the work-in-process account was zero.
Write a payroll applicaion in java : The program should allow the user to enter information for any number of employees in this manner.
Discuss the critical points within service delivery process : Identify and discuss the critical points within the service delivery process that are likely to have a significant bearing on the customer's experience.
Using visual studio for pc,inside the visual c++ : Data and Code to be used for this assignment 3 are attached. Using Visual Studio for PC,Inside the Visual C++ option, we want to select a Win32 Console Application.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd