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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:50:41+00:00 2026-06-05T22:50:41+00:00

As I’m new to java, I would like to know, 1. How many Default

  • 0

As I’m new to java, I would like to know,
1. How many Default constructors are defined when i Make an Empty Class?
2. Does i need to define copy constructor or it is auto defined as in C++?

  • 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-05T22:50:42+00:00Added an answer on June 5, 2026 at 10:50 pm

    There is only one default constructor, which is only defined when you declare no constructors for a class. Otherwise, the declared constructors will be the only constructors. If you do not include a constructor, the compiler inserts code equivalent to

    public ClassName() {
      super();
    }
    

    In addition, if you do declare constructors for a class, and you don’t explicitly define the constructor call of the super class, the compiler will insert a parameter matching call to the super class.

    public ClassName extends SuperClassName {
    
      public ClassName(String item, List stuff) {
        // no explicit super class constructor called
        ...
      }
    
    }
    

    gets transformed in the compiler to something like

    public ClassName extends SuperClassName {
    
      public ClassName(String item, List stuff) {
        // explicit super class constructor call to SuperClassName(item, stuff);
        super(item, stuff); 
        ...
      }
    
    }
    

    To define a copy constructor, there is no special syntax, you basically define a constructor that takes another instance of your class as an argument.

    public ClassName(ClassName other) {
      field = other.field;
      field2 = other.field2;
      field3 = new ArrayList(other.field3);
      ...
    }
    

    There is no such thing as a default copy constructor, actually there is no such thing as a copy constructor, there are just a constructors. If you decide to create one or more that seem to copy an object, so be it.

    The reason that Java needs less types of items is somewhat tied to not overloading basic operators. If you don’t put more meanings on = then you don’t need as many types of constructors to support different methods of object allocation.

    One of the reasons that = can be used so simply is due to Java only passing references, which are sort of like pointers; but, they are strongly typed, you cannot do any pointer math, nor access offsets. As such, they are only good for assignment and passing by reference, which prevents most pointer issues.

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

Sidebar

Related Questions

I would like to count the length of a string with PHP. The string
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
Does anyone know how can I replace this 2 symbol below from the string
I have thousands of HTML files to process using Groovy/Java and I need to
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace

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.