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

  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