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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:34:22+00:00 2026-05-29T16:34:22+00:00

I am somewhat new to JAVA. I’ve been working with it in college, but

  • 0

I am somewhat new to JAVA. I’ve been working with it in college, but I have to admit, my instructor is of absolutely no help. She hardly knows JAVA herself, but that is another issue all in itself. I’ve been confused as to how methods and classes work. I’m creating this program that uses two files, one “main” file, and a “test” file. I can’t seem to get the “main” file correct, as the compiler keeps telling me that it cannot find the symbols, even though they are. In the “test” file, I can’t seem to get the compiler to recognize the methods from the “main” file. I have made sure that the files are in the same folder. I want to combine them into one file for simplicity, but I will lose points. I’ve included my code so far. I’m not looking for a “fix-it” solution, I just want to figure out why it’s not working. ANY help is appreciated, since my instructor isn’t of much assistance Thank you kindly!


MAIN FILE:

import java.util.Scanner;

class Fruit1 {
    static Scanner console = new Scanner(System.in);

    public static void main(String args[]) {

        String color;
        String taste;
    }

    public Fruit1() {
        // generic constructor

        color = "red";
        taste = "yum";

    }

    public Fruit1(String aColor, String aTaste) {
        // constructor with parameters
        color = aColor;
        taste = aTaste;
    }

    public Fruit1(String bColor, String bTaste) {

        color = bColor;
        taste = bTaste;
    }

    String getTaste() {
        return taste;
    }

    String getColor() {
        // Accessor method
        return color;
    }
}

TEST FILE:

import java.util.*;

public class Fruit1Test {

    static Scanner console = new Scanner(System.in);

    public static void main(String args[]){

        Fruit1 a = new Fruit1("pinkish-red", "sweet-tart");
        Fruit1 l = new Fruit1("yellow", "tart/sour");

        a.taste();
        a.color();
        l.taste();
        l.color();

        System.out.println("Your apple is " + a.color + "in color and has a " + a.taste + " taste. ");
        System.out.println("Your lemon is " + l.color + "in color and has a " + l.taste + " taste. ");
        System.out.println();
    }
}
  • 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-29T16:34:25+00:00Added an answer on May 29, 2026 at 4:34 pm

    a.taste(); will try to find method taste(); in your main file i.e. in Fruit1.java file. However as same is not found, it will throw error at compile time only that Method taste() is not found…

    All below 4 statements will FAIL as those are not present…

    a.taste();
    a.color();
    l.taste();
    l.color();
    

    As you are creating object of class by using below statement, already values to taste and color by use of constructor public Fruit1(String aColor, String aTaste){.

    Fruit1 a = new Fruit1("pinkish-red", "sweet-tart");

    I believe you now want to print the values of color and taste. To print those use getter methods that you have (getColor() & getTaste())

    System.out.println("Your apple is " + a.getColor() + " in color and has a " + a.getTaste() + " taste. ");
    
    System.out.println("Your Lemon is " + l.getColor() + " in color and has a " + l.getTaste() + " taste. ");
    

    Note

    You don’t need to write public Fruit1(String bColor, String bTaste){ again as you have already defined above that….

    Also your below statement should be before constructor and out of psvm

    String color;
    String taste;
    

    Let me know if you are unclear…

    Good Luck

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

Sidebar

Related Questions

I am somewhat new to the Java Generics feature. Can you please help me
Im somewhat new in java, been programming for about a year now and im
I am somewhat new to java and was hoping that someone could help me.
I am new to Android, but i know somewhat in Java, and Java EE
I am somewhat new to LINQ and have a quick question regarding deleting. Say,
I am somewhat new to R, and i have this piece of code which
I am somewhat new to jQuery and I have a problem with something I
I'm somewhat new to SQL and need help with query syntax. My issue involves
I'm still somewhat new to Java and trying to insert data into a database.
I apologize in advance for this somewhat ignorant question, but I have researched this

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.