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 8821997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:59:24+00:00 2026-06-14T05:59:24+00:00

I have to create class definiton which could approve argument that the object has

  • 0

I have to create class definiton which could approve argument that the object has already existed at the moment when constructor was inducted.

I have no idea how to explain this, I’ve tried somethin like this but it’s propably wrong:

public class B {

  int obj;

  public B() {  

  }

    public static void main(String[] args) {

    B object = new B();
    System.out.println(object)

    }
}

Code which i wrote, from the first excercise is:

public class Bulb {

static int a;

public Bulb(int ab) {
    a = ab;
}


public static void main(String[] args) {

    Bulb object = new Bulb(a);
    System.out.println(object);

}

And it’s with one parameter constructor.

  • 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-06-14T05:59:26+00:00Added an answer on June 14, 2026 at 5:59 am

    After our long comment thread, it sounds like we’ve determined that what you’re doing is learning about inheritance and polymorphsim. The B class you specified has to inherit from Bulb, and you must prove that Bulb’s constructor is invoked first BEFORE B’s constructor. I’m not certain if there’s any better way than to use log outputs. Your code nearly has everything you need, except for the extension, and logger messages. You can do both like so:

    public class Bulb{
        int ab;
        public Bulb(int ab){
            this.ab = ab;
            System.out.println("Bulb constructor is invoked");
        }
    
        // The rest of your Bulb class
    }
    

    And in the B class, which extends Bulb:

    public class B extends Bulb{
        public B(int ab){
            // Call the super constructor, which in this case is the Bulb constructor
            super(ab);
            System.out.println("B constructor is invoked");
        }
        // The rest of your B class
    }
    

    Does that make sense?

    Edit:
    I forgot to mention: In Java, when you have an inheritance structure, the constructors are always called from top to bottom. Meaning, the top most class in your hierarchy is called first (in this case, that would be Bulb), and trickles down to the bottom (your B class, for example).

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

Sidebar

Related Questions

I want to create a Javascript class/object that allow me to have various method:
I'm trying to create a class that serves as a base object, which will
I have class which has a method that needs to return three DataTables. I
I have create my own NSOpenGLView class, right now the data that i want
I intended to create a class which only have static members and static functions.
I am trying to create a class that implements the IUnknown interface. I have
I have an class definition with a __hash__ function that uses the object properties
I have a List of custom object, which consist of a custom list. class
I have a class myclass that has a private member param_map class some_class {
I have create a Java class extending LinearLayout as shown below public class CustomLinear

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.