Question

What is a null reference reference variable? What happens if we try to print a null...

What is a null reference reference variable? What happens if we try to print a null reference variable? What happens if we try to call an instance method like toString() using a null reference variable?

0 0
Add a comment Improve this question Transcribed image text
Answer #1
null reference reference variable means having an object of value null

if we try to print a null reference variable then it prints null

if we try to call an instance method like toString() using a null reference variable then it throws java.lang.NullPointerException
Add a comment
Know the answer?
Add Answer to:
What is a null reference reference variable? What happens if we try to print a null...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Explain what happens if you: Attempting to refer to an instance field or instance method in...

    Explain what happens if you: Attempting to refer to an instance field or instance method in a static method. In a method that accepts an object as an argument, writing code that accidentally modifies the object. Allowing a null reference to be used.        What is the course of actions that you should take to avoid these situations.

  • Define a class named Payment that contains an instance variable "paymentAmount" (non-static member variable) of type...

    Define a class named Payment that contains an instance variable "paymentAmount" (non-static member variable) of type double that stores the amount of the payment and appropriate accessor (getPaymentAmount() ) and mutator methods. Also create a method named paymentDetails that outputs an English sentence to describe the amount of the payment. Override toString() method to call the paymentDetails() method to print the contents of payment amount and any other details not included in paymentDetails(). Define a class named CashPayment that is...

  • what happens if the new x value (or value we try to predict) is not within...

    what happens if the new x value (or value we try to predict) is not within the range or lies too far from the data thatvwas used to build the regression model

  • Create Student class•Change header so that Student extends Person•A Student has-an additional instance variable, major of...

    Create Student class•Change header so that Student extends Person•A Student has-an additional instance variable, major of type String.•Add the instance variable, its getters and setters. •Add a toString method to the Student class. It should reuse the toString method of Person. •Add two constructors: –No args–Constructor that receives the student’s name, birth year and Major as parameters•Create a class TestInheritance3–Create 2 Student objects–Create an Instructor object–Print the information about the two students and the instructor using the getters of Person,...

  • Assume the null hypothesis was rejected with alpha being 0.05. What happens to the null if...

    Assume the null hypothesis was rejected with alpha being 0.05. What happens to the null if alpha gets changed to 0.10? a) we do not know for sure b) the null gets rejected for sure c) the null doesn't get rejected for sure d) and e) were saying something about a 1% probability that the null gets rejected or doesnt get rejected ( im pretty sure the answer is between a, b or c)

  • Write method createTeams() that Has no parameters Has return type void Instantiate the member variable of...

    Write method createTeams() that Has no parameters Has return type void Instantiate the member variable of type ArrayList<Team> Instantiates two instances of class Team one for TeamOne one for TeamTwo set names for each team as appropriate add each instance to the ArrayList<Team> member variable Instantiate the member variable of class Scanner passing “System.in” as the argument to the constructor Using System.out.println() static method, prompt the user for the human player’s name Instantiate an instance of class String set equal...

  • Try to find out what happens when we press down or up of switch 3? (Please...

    Try to find out what happens when we press down or up of switch 3? (Please refer to the picture given) Table : CPLD USER_REG Register Bit Name R/W Description 7 USER_SW3 User DIP Switch 311 = Off(UP), 0 = On(DOWN)) 6 USER_SW2 User DIP Switch 211 = Off(UP), 0 = On(DOWN)) 5 USER_SW1 User DIP Switch 1(1 = Off(UP), O = On(DOWN)) 4 USER_SWO User DIP Switch 011 = Off(UP), 0 = On(DOWN)) 3 USER_LED3 R/W User-defined LED 3...

  • House Class Specification The House class represents a house. A house has an address (address instance...

    House Class Specification The House class represents a house. A house has an address (address instance variable), a year it was built (built instance variable), and the names of residents of the house (residents instance variable). The declaration of each variable follows. private String address; private int built; private StringBuffer residents; The class methods are: 1. Constructor - Takes a string (representing the address) and an integer (representing the year the house was built) as parameters, and initializes the corresponding...

  • HW question: Write an iterative method printHighEarners() to print all high earner employees. Method printHighEarners()is in...

    HW question: Write an iterative method printHighEarners() to print all high earner employees. Method printHighEarners()is in the class LinkedList. LinkedList has private instance variable list of Node type. Class Node is private inner class inside of class LinkedList, and has public instance variables: data and next of Employee and Node type, respectively. In addition, class Node has constructor and toString method. See LinkedList class bellow on the right. Class Employee has getters for all data, method String toString() that returns...

  • Can you please help me with with problem. please follow all the specific insturctions, and try...

    Can you please help me with with problem. please follow all the specific insturctions, and try to make simple for a beginner in java. Write a class called Shape that contains instance data that represents the name and number of sides of the shape. Define a constructor to initialize these values. Include mutator(setter) methods – with the this reference – for the instance data, and a toString method that returns a the shape data. Create a static variable to keep...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT