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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:03:15+00:00 2026-06-03T06:03:15+00:00

I am doing some basic Java programming where i have to create classes which

  • 0

I am doing some basic Java programming where i have to create classes which have constructors linked to other class constructors. For example, refer to my following code…

public class Friend {

    private String name;
    private Date dateOfBirth;
    private String phoneNum;

    public Friend(String name){
        this.name=name;
        this.dateOfBirth = null;
    }

    public Date setDOB(Date input){
        return dateOfBirth;
    }
}

public class Date {

    final int MINDAYSINMONTH=1; 
    final int MAXDAYSINMONTH=30;
    final int MINMONTHSINYEAR=1; 
    final int MAXMONTHSINYEAR=12;
    private int day;
    private int month;
    private int year;

    //constructor
    public Date(int day, int month, int year){
        this.day=day;
        this.month=month;
        this.year=year;
    }
}

I am trying to create a new Friend, then alter the dateOfBirth value that is within the Friend class, like so…

Friend trial = new Friend(input);
trial.setDOB(new Date(2, 15, 1991));

But my output suggests that i have created a new Friend but the dateOfBirth didn’t change to the values that I supplied above. Could someone please help me understand what I’m doing wrong.

  • 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-03T06:03:16+00:00Added an answer on June 3, 2026 at 6:03 am

    Your setDOB method is wrong – it isn’t actually setting anything at all.

    Try changing this…

    public void setDOB(Date input){
        this.dateOfBirth = input;
    }
    

    You should probably also have a getter method so you can check the value after it has been set…

    public Date getDOB(){
        return dateOfBirth;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im doing some basic socket programming in python. But im having some trouble figuring
I have a java class that extends from JPanel. The basic purpose of extending
I have been doing some java development lately and have started using Eclipse. For
I am having some issues doing basic math with Java. I don't know why
I have basic knowledge of Java and some experience with MVC pattern. I have
I'm doing a fun project in which I'm trying to redo some basic data
Doing some jquery animation. I have certain divs set up with an attribute of
I`m doing some web.config modifications with SPWebConfigModification class. When adding them to WebApplication and
Been doing some playing call my service which is on a different domain using
I am very new to this site and to programming. I started doing some

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.