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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:10:36+00:00 2026-05-26T12:10:36+00:00

This will be my last question for the evening and a while. I have

  • 0

This will be my last question for the evening and a while. I have worked my way through a 100 mark Java assessment and I am now stuck on my final two points. If anyone could help me out, it would be greatly appreciated. I am tired, feeling like a grade-A nub and just want it over with!

Study the two instance methods below and then select only the options that are correct.

public char[] methodA()
{
  char[] alphas = {'s', 't', 'e', 'a', 'm'};
  char temp = alphas[0];
  int i = 0;
  while (i < alphas.length - 1)//1
  {
    alphas[i] = alphas[i+1]; //2
    i++;
  }
  alphas[alphas.length-1]=temp;
  return alphas;
}
public char methodB()
{
  char [] alphas = {'s','a','u','s','a','g','e'};
  char first = alphas[0];
  for (int i= 1; i < alphas.length; i++) //3
  {
    if (alphas[i] < first) //4
    {
      first = alphas[i];
    }
  }
  return first;
}
  1. The assignment statement labelled //2 will put a copy of the char
    element one to the right of the current element in alphas into the
    current element in alphas.

  2. The for loop header labelled //3 will be evaluated 7 times.

  3. The if statement labelled //4 will update the value held by the
    variable first if the value held in the current element in alphas
    comes before the current value of first.

  4. The boolean condition in the line labelled //1 will evaluate to
    false repeatedly until i takes the value 4.

  5. The returned value on invoking methodA is a char array containing
    the values ‘t’, ‘e’, ‘a’, ‘m’ and ‘s’.

  6. The returned value from invoking methodB is the character ‘u’.

I believe 1 to be true. Not sure why.
I think 2 is false as the for loop is evaluated 6x, not 7.
Not sure on 3 or 4.
5 I got to be true
6 I got to be false.

If anyone can help I owe them a beer, a cookie and a cuddle!!

  • 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-26T12:10:37+00:00Added an answer on May 26, 2026 at 12:10 pm
    1. It is true because alphas[i] = alphas[i+1] essentially will take element at position i and and replace it with the next element in the array at i + 1 (or another way to say it, its adjacent element).

    2. I believe this is false, the keyword here is evaluated. A loop will evaluate to the stopping point, check the exiting condition, then kick out. So it will finish evaluating 1, 2, 3, 4, 5, 6, 7 <— evaluates the value and kicks

    3. This will be true. the expression if (alphas[i] < first) is asking if the value stored in first is greater than the value in alphas[i] or inversely … if alphas[i] is less than first. This is essentially performing a max/min algorithm because the final number in first will be the smallest value in the alphas array. In this case, the letters will be evaluated based upon their ascii values.

    4. This is false. The expression will evaluate to true until 4. If this were not the case then the question 1 would not be true because it would simply throw an IndexOutOfBoundsException.

    5. This is true, because it is taking the adjacent char and placing it in the current position, then the line alphas[alphas.length-1]=temp puts the first char into the last position. More specifically, after the while your array will look like this: { t, e, a, m, m } then after the last line it will complete the set with { t, e, a, m, s }

    6. The last one is false. Like I mentioned in question 3, it is essentially performing a min search. the character u has a greater valued ascii value than any other letter in the sequence. a is the lowest letter in the set.

    Great job on making an attempt.

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

Sidebar

Related Questions

This should be my last question on Jquery Sortable...for a while :) I have
I'm hoping this will be my last question today. I'm in a hurry and
I'm going to give this another try because my last question might have been
I have a question. Currently this form will be dynamically generated. Example, <form method=POST>
Hopefully this will be the last question I need to ask about this..lol.. I
i've made a php search engine a while ago and now i have this
Ok, I hope this will be my last question in a series of Q's
This will hopefully be an easy one. I have an F# project (latest F#
This will probably be obvious but I can't find the best way. I want
This will be probable quite odd question. But i thought I will give it

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.