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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:27:31+00:00 2026-06-15T11:27:31+00:00

Is there a constructor in this piece of code? Which part in this code

  • 0

Is there a constructor in this piece of code? Which part in this code is the constructor?

class Bicycle {
    int cadance = 0;
    int speed = 0;
    int gear = 0;

    void changeCadance(int changeCadence) {
        cadance = changeCadence;
    }

    void changeGear(int changeGear) {
        gear = changeGear;
    }

    void changeSpeed(int changeSpeed) {
        speed = changeSpeed;
    }

    void printState() {
        System.out.print("Cadance = "+cadance);
    }
}
  • 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-15T11:27:31+00:00Added an answer on June 15, 2026 at 11:27 am

    What you have there is an implied default constructor. It is never spelled out, but it is understood to be there by the IDE and compiler. Non static classes are generally understood to have a constructor, and thus if no constructor is created explicitly, the default constructor is used. It takes no arguments, and does not really do anything but initialize the class with the explicitly provided property values. Sometimes, you can get away with just the default.

    For a little more information, I am linking the Wikipedia article for Default Constructor as I think it does a pretty good job of explaining it across several languages.

    Essentially it says that the default constructor is supplied by the compiler (and the IDE will normally allow you to call it also) if a parameterless constructor is not explicitly given in the class. So if I write a constructor that takes and parameter, but I don’t write a constructor that takes no arguments, the compiler will STILL supply one.

    This is a bit of a generalization as some languages differ a bit, but I think that most doe the above.

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

Sidebar

Related Questions

If I have a piece of code that looks like this: - (void)testSomething {
I have this piece of code which is throwing a Null Pointer exception at
In JCIP we have a piece of code which looks like this: Listing 4.2:
In .NET, there is a constructor for Dictionary<TKey, TValue> that takes one parameter, int
Is there any sense to declare default constructor in Java? class MyClass { public
Is there any way to tell db4o to call class default constructor while activating
I wonder if there is something wrong with the copy constructor function below? class
How does Castle Windsor determine which constructor to resolve when there are multiple constructors
As part of answering another question, I came across a piece of code like
Hey, in a tutorial C++ code, I found this particular piece of confusion: PlasmaTutorial1::PlasmaTutorial1(QObject

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.