Question

1-To create an ArrayList of strings, which of the following is correct? `a ArrayList<String> list =...

1-To create an ArrayList of strings, which of the following is correct?

`a

ArrayList<String> list = new ArrayList<String>();

b

ArrayList<String> list = new String<String>​[];

c

ArrayList<String> list = new ArrayList<String>;

d

ArrayList​[String] list = new ArrayList​[String];

2-All instance variables?

a

Are assigned a default value if they are not initialized

b

Must be initialized as part of their declaration

c

Are assigned an arbitrary value if they are not initialized

d

Must be initialized by the constructor

3-An instance method may only be invoked on

a

An instance variable

b

A constructor

c

A class

d

An object

4-Each object contains its own copy of

a

Constructors

b

Constructors, methods, and variables

c

Instance variables

d

Instance methods

Please provide a correct answer..

Note that the questions are about java.

Homework Answers

Answer #1

Ans1) Correct Option :- A ArrayList<String> list = new ArrayList<String>();

Explanation :- As it is the correct syntax to create the array list.

Ans2) Correct Option : A  Are assigned a default value if they are not initialized

Explanation :- Since, instance variable have default value. For numbers, the default value is 0, for booleans it is False, and for object references it is null.

Ans3) Correct Option : D An object

Explanation :- To call a instance method, we have to create an Object of the class within which it defined.

Ans4) Correct Option : B Constructors, methods, and variables

Explanation :- Since, each object is blue print of the class.

Know the answer?
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
Similar Questions
The following is for a Java Program Create UML Class Diagram for these 4 java classes....
The following is for a Java Program Create UML Class Diagram for these 4 java classes. The diagram should include: 1) All instance variables, including type and access specifier (+, -); 2) All methods, including parameter list, return type and access specifier (+, -); 3) Include Generalization and Aggregation where appropriate. Java Classes description: 1. User Class 1.1 Subclass of Account class. 1.2 Instance variables __ 1.2.1 username – String __ 1.2.2 fullName – String __ 1.2.3 deptCode – int...
Create a class called Employee that contains three instance variables (First Name (String), Last Name (String),...
Create a class called Employee that contains three instance variables (First Name (String), Last Name (String), Monthly Salary (double)). Create a constructor that initializes these variables. Define set and get methods for each variable. If the monthly salary is not positive, do not set the salary. Create a separate test class called EmployeeTest that will use the Employee class. By running this class, create two employees (Employee object) and print the annual salary of each employee (object). Then set the...
JAVA QUIZ Question 1 Which of the following is false about a "super" call in a...
JAVA QUIZ Question 1 Which of the following is false about a "super" call in a sub class's constructor? Select one: a. It must be the first statement in the constructor b. If you don't include it Java will c. If you don't include it you must have a 0 parameter constructor coded in the super class or no constructors coded at all in the super class d. The sub class constructor containing the super call and the called super...
A stack can be used to print numbers in other bases (multi-base output). Examples: (Base8) 2810...
A stack can be used to print numbers in other bases (multi-base output). Examples: (Base8) 2810 = 3 * 81 + 4 * 80 = 348 (Base4) 7210 = 1 * 43 + 0 * 42 + 2 * 41 + 0 * 4 = 10204 (Base 2) 5310 = 1 * 25 + 1*24 + 0 * 23 + 1 * 22 + 0 * 21 + 1 * 20 = 1101012 Write a java program using stacks that...
java Write a single Java statements to accomplish each of the following: a) Displaythevalueoftheseventhelementofcharacterarraych. b) Considering...
java Write a single Java statements to accomplish each of the following: a) Displaythevalueoftheseventhelementofcharacterarraych. b) Considering “Scanner in = new Scanner (System.in);”, input a value into element 5 of one-dimensional double array nums. c) Initialize each of the four elements of the one-dimensional integer array test to 7. d) Declare and create an array called table as a float array that has four rows and three columns. e) Considering the following ArrayList declaration, insert “test” at the fourth position (index...
main The main method instantiates an ArrayList object, using the Car class. So, the ArrayList will...
main The main method instantiates an ArrayList object, using the Car class. So, the ArrayList will be filled with Car objects. It will call the displayMenu method to display the menu. Use a sentinel-controlled loop to read the user’s choice from stdin, call the appropriate method based on their choice, and redisplay the menu by calling displayMenu. Be sure to use the most appropriate statement for this type of repetition. displayMenu Parameters:             none Return value:          none Be sure to use...
TODO 1: Constructor. It assigns the songList member variable to a new instance of an ArrayList...
TODO 1: Constructor. It assigns the songList member variable to a new instance of an ArrayList that stores Song objects.. TODO 2: Implement the isEmpty method. Takes no parameters. Returns true if there are no songs on the list, false otherwise. TODO 3: Implement the addSong method. This method takes a Song object as a parameter and does not return a value. It adds the song to the songList. TODO 4: Implement the getSongListAsString method. This method takes no parameters....
Design a class with the following requirements: 1- give the class a name from your choice....
Design a class with the following requirements: 1- give the class a name from your choice. 2- write some code that creates three instance variables, choose a name and type for each one of them. (must have two private and one public variables) 3- Initialize the variables using two different constructors. 4- Use mutator and accessor methods (set and get) for the private data members. 5- Display the value of each member variable using a method. 6- In the main,...
Design a class with the following requirements: 1- give the class a name from your choice....
Design a class with the following requirements: 1- give the class a name from your choice. 2- write some code that creates three instance variables, choose a name and type for each one of them. (must have two private and one public variables) 3- Initialize the variables using two different constructors. 4- Use mutator and accessor methods (set and get) for the private data members. 5- Display the value of each member variable using a method. 6- In the main,...
Create a class called Student. Include the following instance variables: name, address, phone, gpa Create all...
Create a class called Student. Include the following instance variables: name, address, phone, gpa Create all of the methods required for a standard user defined class: constructors, accessors, mutators, toString, equals Create the client for testing the Student class (5 points extra credit) Create another class called CourseSection (20 points extra credit) Include instance variables for: course name, days and times course meets (String), description of course, student a, student b, student c (all of type Student) Create all of...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT