Java Project
|
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?
|
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?
|
A: A only |
|
B: A & b |
|
|
C: B only |
|
|
D: D only |
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
Java Project Create a NetBeans project for this activity. Test Stem / Question Choices 1: Create...
JAVA LANG PACKAGE Create a NetBeans project for this activity. 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 to String() method. 2: Create a class with the main method and create an instance of the class that you created 3: Create an instance of the string in your test class and assign a value. 4: Now create an String...
Hi, I need help with this Java activity. The requirements are: 1. Create a NetBeans project for this activity. 2. 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. 3. Create a class with the main method and create an instance of the class that you created in Test Stem 1. 4. Create an instance of the string in your test class and assign...
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 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) 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...
Tip Calculator App & Order Using NetBeans create a new JavaFX project with two classes TipCalculator (the JavaFX class) and Order Create the Tip Calculator as follows: Start with an Order class with two instance variables, item a String and price a double; include two constructors, a no-parameter constructor that passes default values empty String and zero (0) to the second constructor which then calls the set methods for item and price; the set method for price validates that price...
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 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 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...
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...