Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7489089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:11:55+00:00 2026-05-29T15:11:55+00:00

I have class GUI so I can create object like this: GUI g1 =

  • 0

I have class GUI so I can create object like this:

GUI g1 = new GUI();

and a reference variable like this:

GUI g2;

Now as much as I know, g2 is a reference variable which gives reference to GUI class and g1 is an object of GUI class. What is the difference between g1 and g2? I can use property of GUI class with object but what is the possible usage of g2?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T15:11:56+00:00Added an answer on May 29, 2026 at 3:11 pm

    References are names. Objects are stuff. You can have different names for stuff, even for stuff that doesn’t actually exist.

    You can declare names, without actually giving them any “real” meaning, like this:

    GUI g1;
    

    You can assign meaning (real stuff to refer to) to names with the = operator:

    GUI g1 = some_gui;
    

    Names can change their meaning over time. The same name can refer to different things at different points in history.

    GUI g1 = some_gui;
    
    doSomething();
    
    g1 = some_other_gui;
    

    There are also synonyms: multiple names can refer to the same thing:

    GUI g2 = g1;
    

    That’s pretty much what references do. They are names meant to refer to stuff.

    Stuff can be created:

    new GUI();
    

    Stuff can be created and named on the spot for later reference (literally!):

    GUI g1 = new GUI();
    

    And stuff can be referred to, using its name (or any of its names!):

    g1.doSomething();
    g2.doSomethingAgain();
    

    Different stuff of the same kind (Class) can be created, and named differently:

    GUI g1 = new GUI();
    GUI g2 = new GUI();
    GUI g3 = new GUI();
    
    GUI g1_synonym = g1;
    

    🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class like this class GUI : public QWidget, public QThread When
I have a class (simulation) which creates an instance of another class (GUI). Inside
I currently have a class and I'm trying to create an easy GUI to
i have a class which, when a certain part of the gui is clicked
I have a class let's say MyJFrame which represent the GUI of my application.
I have a GUI tool that manages state sequences. One component is a class
I have a simple GUI component written in Java. The class draws an analog
Say I have two classes, and neither of them are GUI components. Class A
I have class method that returns a list of employees that I can iterate
I have written this short script (which I've stripped away some minor detail for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.