Why does the program end abnormally

Assignment Help JAVA Programming
Reference no: EM13940239

Using the Person and PersonRunner classes below, execute the main method in PersonRunner. Why does the program end abnormally? Comment out the first two lines and run the program again. Why does the reference to p3 cause Frank's name to be printed when we set Frank's name with the p2 reference?
public class PersonRunner
{
public static void main(String[] args)
{
Person p1 = null;
p1.speak();
Person p2 = new Person("Beth");
p2.speak();
Person p3 = p2;
p2.speak();
p2.setName("Frank");
p3.speak();
}
}

public class Person
{
private String name;

public Person(String name)
{
this.name = name;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void speak()
{
System.out.println("My name is " + name);
}
}

Reference no: EM13940239

Questions Cloud

How do you figure out how to declare a variable : How do you figure out how to declare a variable? How do you know what type of variable to use? What is the best way to name a variable and why? What are the differences between an integer variable and a floating point variable? When and why do dat..
What is the value of etc according to mm with corporate tax : What is the value of ETC according to MM with corporate taxes?  What is ETC's value (rounded to the nearest 1000) according to MM (including personal taxes)?
How many trim kits must be sold for polaris to break even : If Polaris sells 20,000 door handles and 40,000 trim kits, what is the operating income? How many door handles and how many trim kits must be sold for Polaris to break even?
Should a property owner be allowed to use a bobby trap : Contrary to common law, today, in most states, a person cannot use deadly force in the defense of their property. Do you agree with this challenge? Should a property owner be allowed to use a bobby trap as long as notice, by use of sign for exampl..
Why does the program end abnormally : Using the Person and PersonRunner classes below, execute the main method in PersonRunner. Why does the program end abnormally?
What percent of students take exactly two courses : Fifty part-time students were asked how many courses they were taking this term. The (incomplete) results are shown below: What percent of students take exactly two courses
The management team is extremely interested : The management team is extremely interested in the new system you are introducing, but there are concerns about the introduction. As the changes are introduced into the system to support the new topic, new risks will be introduced.
Normal balance per the general ledger : Cash received from a customer on account was debited for $780, and Accounts Receivable was credited for the same amount. The actual collection was for $870.
Difference between an arrest warrant and a search warrant : Why do you think a search warrant requires probable cause that the items to be seized are in the location to be searched, but an arrest warrant does not have the same requirement?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Concepts of polymorphism

This lab introduces students to the concepts of polymorphism, early binding, late binding, abstract classes, and virtual class functions. This will be done in the context of performing calculations on basic geometrical shapes

  How many data items are within one standard deviation

How many data items are within One Standard Deviation - Generate a list of 100 values between 0 and 100 using the generator (int)(Math.random()*101).

  Role of inheritance in object-oriented programming

role of inheritance in object-oriented programming

  Use data structures and algorithm to implement search engine

For the URLs in the keyword list, sort them by either the number of times the keyword appearing in the pages or the popularity of the pages.

  Write program to keep track of a hardware stores inventory

Write a program to keep track of a hardware store's inventory. The store sells various items. For each item in the store, the following information is kept: item ID, item name, number of pieces in stock, manufacturer's price of the item, and the s..

  Employee type and the number of hours

Write a program that calculates the salary for the employee. The hourly rate for permanent staff (P) is 200, contract staff (C) is 150 and temporary staff (T) is 100. The program accepts the employee type and the number of hours the employee work.

  Implement savings account using locks and conditions

A savings account object holds a non-negative balance - Use a shared counter protected by test-and-test-and-set lock. Each thread locks the counter, increments it, releases the lock, and repeatedly reads the counter until it reaches n.

  Sample papaer hello can you please help me to solve this

hello can you please help me to solve this sample paper and there is not submit date as this is for me but still i want

  Allow the user to display a work history report

The 'report screen' shall:Allow the user to display a work history report for an individual or for all employees for the two weeks prior to the report request.

  What is jsp and why do we need it?

What is JSP and why do we need it?

  Number of space characters in a string

Write a loop that counts the number of space characters in a string - You need to implement a program to find the number of spaces.

  Declare another television object called portable

Add to the comment header as indicated at the top of the program.

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