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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:01:10+00:00 2026-06-16T00:01:10+00:00

Just looking at past exam papers and stumbled across the following question which doesn’t

  • 0

Just looking at past exam papers and stumbled across the following question which doesn’t make much sense to me:

The following piece of code is meant to greet the user in an appropriate manner:

public static void main( String[] args ) {
    System.out.println("Enter a name");
    String name = EasyIn.getString();
    if (name == "" ) 
        System.out.println("You must input a name");
    else 
        System.out.println("Hello, " + name);
}

The question asks why the program may not do what the programmer intended. With a lack of a laptop at the moment (spilt drink on it!) I can’t test the code with different inputs etc. From what I can tell, the only problem with it is that it doesn’t ask the user for another input of name if it is blank, and just terminates the program. I’d use this as the answer, but it is brought up later on in the question directly which makes me think it isn’t the answer they’re looking for. Are there any other problems with the code?

  • 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-16T00:01:10+00:00Added an answer on June 16, 2026 at 12:01 am

    Another String.equals question, replace:

    if (name == "" )
    

    with

    if (name.equals(""))
    

    The == operator compares object references, You need to use String.equals to compare String content. Alternatively you could use:

    if (name.IsEmpty())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started looking into selenium for automated testing for the past few days
I am not looking for the answer to this question but just a brief
Hey, just doing some revision for upcoming exams and i'm looking at a past
Just looking for a good PHP Image Library, I want to display images with
Just looking on resources that break down how frames per second work. I know
I just looking how to use LINQ for grouping a list. Class Item Public
Basically just looking to see if you can capture an image from the webcam
I was just looking at this example from Deitel : #include <stdio.h> struct card
I was just looking at the MySql database created by drupal after I installed
I'm just looking for suggestions on the best way to do this... I need

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.