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

  • Home
  • SEARCH
  • 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 7612253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:51:51+00:00 2026-05-31T01:51:51+00:00

// Create a class called Dog containing two String: name and says. In main(),

  • 0
// Create a class called Dog containing two String: name and says. In main(), create two dogs objects
and assign it to spot's object.  

class Dog {
    String name;
    String says;
}

public class DogSays {
    public static void main(String[] args) {
        Dog D1 = new Dog();
        Dog D2 = new Dog();

        D1.says = "Woof!";
        D1.name = "Scruffy!";

        D2.says = "Bark!";
        D2.name = "Spot!";
        System.out.println("Hi! My name is " + D1.name);
        System.out.println(D1.says);
        System.out.println("Rooooooooowr! I'm " + D2.name);
        System.out.println(D2.says);
    }
}

I’ve been checking this for an hour and I don’t have any idea what’s wrong. I get a class, enum, or interface error expected and also a unclosed character literal. I think it’ something with the quotes.

  • 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-31T01:51:52+00:00Added an answer on May 31, 2026 at 1:51 am

    The problem “Unclosed character literal” is here:

    //Exercise2.5 Create a class called Dog containing two String: name and says. In main(), create two dogs objects
    and assign it to spot's object.
    

    Make it:

    //Exercise2.5 Create a class called Dog containing two String: name and says. In main(), create two dogs objects
    //and assign it to spot's object.
    

    You can not have stray comments without leading // or not enclosed in /* and */ pairs…

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

Sidebar

Related Questions

Ok so I have a class called Dog() which takes two parameters, a string
I'm having some trouble creating an object in C++. I create a class called
I'd like to create a class called Object to be able to implement toString(),
I would like to create a class whose methods can be called from multiple
I'm trying to create a point class which defines a property called coordinate. However,
Can I create a private instance method that can be called by a class
I need to create class Dog and PurebredDog extending Dog. Problem is that Dog
i create a class called Data and call it in JSP.. when i comple
Basically, what I want to do is create a class called Variables that uses
For my latest CS homework, I am required to create a class called Movie

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.