XML

COMP3200 Anonymous Questions and Answers

This page lists the various questions and answers. To submit a question, use the anonymous questions page. You may find the keyword index and/or top-level index useful for locating past questions and answers.

We have taken the liberty of making some minor typographical corrections to some of the questions as originally put. Although most of the questions here will have been submitted anonymously, this page also serves to answer some questions of general interest to those on the course.


Question 161:

Submission reference: IN2734

Open the tech-support1 project. Find the following code in the getInput method of the InputReader class:
String inputLine = reader.nextLine();

return inputLine;
Edit the method so that the String that is returned does not have spaces at either end of it. (Use the API documentation for the String class to work out how to do that.)
Can I have some help with this because I don't really understand what I'm supposed to do please.

Answer 161:

Open the API documentation for the String class and search for the word space on the page. You will quickly find several methods that can be called on a String to remove spaces from various places. Use one of the method you find that way to complete the exercise.


Question 160:

Submission reference: IN2730

What does arg mean? This is related to making a main method.

Answer 160:

In the following, args is the name of the parameter received from outside the program. Argument and parameter mean the same thing, so it is short for 'arguments':

public static void main(String[] args)

Keywords: main-method


Question 159:

Submission reference: IN2729

when it says "Consider placing the main method in a separate class. " does this means in an diffrent java file because should only have one class per file?

Answer 159:

Yes, that is right. A separate file.

Keywords: main-method


Question 158:

Submission reference: IN2720

In one of our lectures this week ( i forgot which one) you said that for the in class assignment there will be practice examples or something to help us prepare for that in advance. However after looking at moodle I have not seen anything yet, is this going to be set soon or is it meant to be set a few days before the actual assesement?

Answer 158:

I will make it available early this week (week 18/10) so that you have a reasonable amount of time to practice before the real thing in week 19/11.

Keywords: assign5


Question 157:

Submission reference: IN2719

Hi, Have you got any advice for second years?

Also, I now have only 2 spoons for hot chocolate.

Answer 157:

I do confess to be slightly baffled by these questions, but I will do my best to answer them.

My advice to second years is to ensure that you progress to the final year.

2 spoons are perfectly sufficient to become a competent programmer, so no worries there.

Keywords: hot-chocolate , spoons


Question 156:

Submission reference: IN2718

for Question 155 (2022), would this be correct.

code deleted

Answer 156:

Yes, that is correct.

Keywords: ex-7-20


Question 155:

Submission reference: IN2716

im struggling for the returning one item from the list exerise, this is what i have.

code deleted

Answer 155:

You have the right pieces but have not yet connected them in the right way. When calling the get method on a list, you need to provide a parameter. That parameter must be the index you want to select. So, think of it this way:

return list.get(random-integer-value);

Keywords: ex-7-20

Referrers: Question 156 (2022)


Question 154:

Submission reference: IN2713

for exercise 7.10, Edit the method so that the String that is returned does not have spaces at either end of it, would we use the deleted method or the deleted method. Im unsure on the differences

Answer 154:

Yes, either of those is fine. One has a slightly different effect than the other but, for the purposes of this exercises, both are fine to use.

Keywords: ex-7-10


Question 153:

Submission reference: IN2712

how do i join the homework club

Answer 153:

You just turn up to room SW18 in the basement of Computing on one of the session times, which are:

Keywords: homework-club


Question 152:

Submission reference: IN2711

for Question 150 (2022), would this be correct.

code deleted
lower will be a String variable.

Answer 152:

No because Strings are immutable, so calling toLowerCase on a String does not change the String it is called on. That is the case with all methods, such as trim, substring, etc.


Question 151:

Submission reference: IN2710

I was thinking about how useful the vevox question asking is and was wondering do other programming modules use it?

Answer 151:

We are glad that you find it useful. I am not aware of any others that use it in the way that we do. At the end of the module there will be a chance to provide further feedback on all your modules and it would be worth highlighting the value of it in this module's feedback, because we do report back to the Board of Studies and others might pick up on that.

Keywords: vevox , module-feedback


Question 150:

Submission reference: IN2709

im struggling to understand what this means.

Write down a call to the toLowerCase method on a String variable called text and store the result of the call in a variable called lower. What must the type of the variable lower be?

Answer 150:

It means, suppose you have a variable of type String called text and you call its toLowerCase method. What is the type of the result.

Referrers: Question 152 (2022)


Question 149:

Submission reference: IN2708

i am stuck on the 2 last question of class 7 week 17 excersises how to we iterate throught a HashMap collection? i have tried for each which is not possible and while trying to use a while loop i found hashmap does not have an iterator method.

Answer 149:

The simplest way is either to iterate over its keys or its values. There are methods for both in the API documentation for HashMap.

Keywords: class-HashMap


Question 148:

Submission reference: IN2707

when will the mock be available, also will we need hash for the assessment

Answer 148:

I will make it available shortly. HashMaps could be included in the assessment, along with any other material covered on the course up to the point of the assessment.

Keywords: assign5 , mock


Question 147:

Submission reference: IN2706

Can you start to post solutions to the weekly class exercises

Answer 147:

I won't be posting solutions to the class exercises.


Question 146:

Submission reference: IN2705

when using java api i am Not sure how to tell difference between if method will change the string its called on or results in creation of new one with slightly different contents.

the trim method change string its called on while the toLowerCase method results in creation of new string with slightly diffrent contents but i cannot tell the diffrence from the api documentaion.

Answer 146:

In fact, none of the String methods actually change the contents of the string they are called on because strings are immutable. All of the methods like trim and toLowerCase return a new version of the original string.

Keywords: API


Question 145:

Submission reference: IN2704

Do we need to attend the class in week 20/12 if we get all our work marked off in 18/10?

Answer 145:

There will be further exercises to complete in the week 20 class.

Keywords: class-exercises , week-20


Question 144:

Submission reference: IN2703

Hello, my test assistance centre is not testing or compiling. It keeps on saying there is a problem with this method, the centre.list line :

/**
     * Test the list method.
     * Note that this method does not check the
     * format of the output.
     */
    public void list()
    {
	centre = new AssistantCentre();
	makeAssistant(1, 2, false);
	makeAssistant(5, 1, true);
	centre.list();
    }
Could you help with this?

Answer 144:

I suspect you have made an inappropriate change to the header of the list method in AssistantCentre.

Keywords: assign2 , method-list


Question 143:

Submission reference: IN2702

why is the first if statement not working? and why is the rest of it not working?

code deleted

Answer 143:

You have a return statement in the body of the loop, so not every assistant is examined for being the closest.

Keywords: assign2 , method-findNearestAvailable


Question 142:

Submission reference: IN2701

for Question 93 (2022), would this be of better quality?

code deleted

Answer 142:

Yes, that is very good. Just note that instead of:

if(available == true)

you can simply write

if(available)

Keywords: assign2 , method-setAvailability

This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.
Last modified Fri Jan 27 11:32:30 2023
This document is maintained by David Barnes, to whom any comments and corrections should be addressed.