Question

Java Project Create a NetBeans project for this activity. Test Stem / Question Choices 1: Create...

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

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1. A: Yes.
2. A: hashCode()
3. A: int
4. A: a, d & e


Explanation
String a = "Chegg" + "India";
a += "Rocks";
int l = a.length()

Note: 4 sub parts at a time please -- Policy of Chegg

Add a comment
Know the answer?
Add Answer to:
Java Project Create a NetBeans project for this activity. Test Stem / Question Choices 1: Create...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • signature 1. Create a new NetBeans Java project. The name of the project has to be...

    signature 1. Create a new NetBeans Java project. The name of the project has to be the first part of the name you write on the test sheet. The name of the package has to be testo You can chose a name for the Main class. (2p) 2. Create a new class named Address in the test Two package. This class has the following attributes: city: String-the name of the city zip: int - the ZIP code of the city...

  • MasterMind in Java Activity MasterMind project Create a new Java Application project named MasterMind allowing Netbeans...

    MasterMind in Java Activity MasterMind project Create a new Java Application project named MasterMind allowing Netbeans IDE to create the main class called MasterMind.java MasterMind class Method main() should: Call static method System.out.println() and result in displaying “Welcome to MasterMind!” Call static method JOptionPane.showMessageDialog(arg1, arg2) and result in displaying a message dialog displaying “Let’s Play MasterMind!” Instantiate an instance of class Game() constants Create package Constants class Create class Constants Create constants by declaring them as “public static final”: public...

  • Create a NetBeans project called "Question 1". Then create a public class inside question1 package called Author according to the following information (Make sure to check the UML diagram)

    Create a NetBeans project called "Question 1". Then create a public class inside question1 package called Author according to the following information (Make sure to check the UML diagram) Author -name:String -email:String -gender:char +Author(name:String, email:String, gender:char) +getName():String +getEmail):String +setEmail (email:String):void +getGender():char +tostring ):String . Three private instance variables: name (String), email (String), and gender (char of either 'm' or 'f'): One constructor to initialize the name, email and gender with the given values . Getters and setters: get Name (), getEmail() and getGender (). There are no setters for name and...

  • help please Perform the following steps: a) Using NetBeans, Create a New Java Application Project with...

    help please Perform the following steps: a) Using NetBeans, Create a New Java Application Project with Project Name BasePlusCommission Employee Test with Create Main Class check box selected. Create comments to form a descriptive header that has the course name, your name, the assignment title, and a pledge that you have neither received nor provided help to any person. Assignments submitted without this pledge will not be graded. When you have completed the steps (b) and (c) below, you will...

  • Create a java project. Create a class called cls2DarrayProcessor.java. with the following: Reads numbers from a...

    Create a java project. Create a class called cls2DarrayProcessor.java. with the following: Reads numbers from a pre-defined text file. A: Text file name should be data.txt B: Text file should be in the same workspace directory of your project's folder C: Text file name should be STORED in a String and called: String strFile ='./data.txt' Defines a 2-D array of integers with dimensions of 5 rows by 5 columns. Inserts the data from the text file to the 2-D array...

  • Java Netbeans code Option 1: Authentication System For security-minded professionals, it is important that only the...

    Java Netbeans code Option 1: Authentication System For security-minded professionals, it is important that only the appropriate people gain access to data in a computer system. This is called authentication. Once users gain entry, it is also important that they only see data related to their role in a computer system. This is called authorization. For the zoo, you will develop an authentication system that manages both authentication and authorization. You have been given a credentials file that contains credential...

  • Generics Objectives: OOWorking with a Generic Class 1. Create a class called Node that is Generic...

    java Generics Objectives: OOWorking with a Generic Class 1. Create a class called Node that is Generic. The class has one class attribute that is an element. It will need 2 Constructors, a setter and getter for the class attribute, and a toString method. 2. Write a Lab10Driver that will: Instantiate a Node Integer object with no value. I. Il. Ill. IV. a. Then call the set method to set the value to 5. Instantiate a Node String object with...

  • I need help for part B and C 1) Create a new project in NetBeans called...

    I need help for part B and C 1) Create a new project in NetBeans called Lab6Inheritance. Add a new Java class to the project called Person. 2) The UML class diagram for Person is as follows: Person - name: String - id: int + Person( String name, int id) + getName(): String + getido: int + display(): void 3) Add fields to Person class. 4) Add the constructor and the getters to person class. 5) Add the display() method,...

  • In NetBeans Create a new Java Application to manage Linked Lists: (Note: Do not use java.util.LinkedList)...

    In NetBeans Create a new Java Application to manage Linked Lists: (Note: Do not use java.util.LinkedList) a) Create a DateTime class 1. Add day, month, year, hours, minutes as attributes 2. Add a constructor and a toString() method 3. Implement the Comparable interface, and add a CompareTo() method 4. Add methods to get and set all attributes. b) Add to MyLinkedList class the following methods: 1. Insert a Node to a particular position in the List 2. Insert a Node...

  • Hello, In need of help with this Java pa homework. Thank you! 2. Create a normal...

    Hello, In need of help with this Java pa homework. Thank you! 2. Create a normal (POJo, JavaBean) class to represent, i. e. model, varieties of green beans (also known as string beans or snap beans). Following the steps shown in "Assignment: Tutorial on Creating Classes in IntelliJ", create the class in a file of its own in the same package as class Main. Name the class an appropriate name. The class must have (a) private field variables of appropriate...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT