Zookal
Zookal

We’d love to hear any feedback or comment from you!

© 2011-2021 Zookal Pty Ltd

View question and answer

From our collection of questions and answers
Engineering · Computer Science
Question details

Java Project

  • Create a NetBeans project for this activity.

Test Stem / Question

Choices

1: Create a new class with attributes name and address. Both data type will be String. Create a constructor and assign the parameters to the attributes.

Now override the toString() method.

Is this possible?

A: Yes.

B: No.

C: In some cases where the attributes are only strings.

D: Yes, as long as you explicitly extends Object class.

2: Create a class with the main method and create an instance of the class that you created in Test Stem

1. What method can you call to get the hashCode of your class?

A: hashCode()

B: getHash();

C: getHashCode();

D: toHashCode();

3: What is the return type of the hash code ?

A: int

B: byte

C: byte[]

D: String

4: Create an instance of the string in your test class and assign a value. Which of the following operators can be used in conjunction with a string object?

  1. +
  2. -
  3. &
  4. .
  5. +=

A: a, d & e

B: a & e

C: d & e

D: b, d & e

5: Supposed that we have a string with a value “This is my string.”.

Which method can be used to extract a specific word from the given string?

A: substring

B: concat

C: extract

D: get

6: Supposed that we have a string with a value “This is my string.”.

Which expression can be used to extract the word “my” from the given string?

A: string.substring(8, 10)

B: string.get(“my”)

C: string.extract(“my”);

D: string.concat(8, 2)

7: Now create an String and assign a value with spaces in the beginning, end and middle.

Try out the method trim(). What does it do?

A: It removes all the leading and trailing spaces in the string.

B: It removes all the spaces in the string; basically combining all the words in the string

C: It removes all the leading spaces of the string

D: It trims the trailing spaces of the string.

8: In your test class with main method, instantiate a string buffer with the initial value of “hello”.

How will you be able to do that?

A: StringBuffer sb = new StringBuffer("hello");

B: StringBuffer sb = new StringBuffer();

sb.initialize(“hello”);

C: StringBuffer sb = new StringBuffer().init(“hello”);

D: StringBuffer sb = “hello”;

9: In your test class with main method, instantiate a string buffer with the initial value of “hello”.

Use the method setLength with parameter 2. Print the string representation of the StringBuffer using toString(). What is the result?

A: It changed the size of the string buffer and printed “he”

B: it added two additional blank characters in the initial value.

C: Nothing happened since the initial length is bigger than the value assign to the setLength method.

D: It reduces the size of the StringBuffer by 2 and printed “hel”

10: Which method is not defined in the StringBuffer class?

  1. appends
  2. codePointCount
  3. insert
  4. lastIndexOf

A: A only

B: A & b

C: B only

D: D only

Answer
Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.

Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.