Question

I need help with 3 - 6, 9 & 10 QUESTION 3 To call a static...

I need help with 3 - 6, 9 & 10

QUESTION 3

To call a static method you first need to create an instance of a class.

True

False

QUESTION 4

If a field is static, it gets copied to all instances of that class

True

False

QUESTION 5

A static method can call an instance method

True

False

QUESTION 6

When a method receives an object as an argument, the method can change the values of its fields.

True

False

QUESTION 9

Consider the following source code;

Stock stock1 = new Stock( "XIV", 119.5 );

Stock stock2 = stock1;

The variable stock2 points to a copy of the stock1 instance.

True

False

QUESTION 10

You can't have an instance of a class to be a field of another class.

True

False

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

QUESTION 3

To call a static method you first need to create an instance of a class.
Answer: False (Static method can be called directly using the name of the class,


QUESTION 4

If a field is static, it gets copied to all instances of that class
Answer: True (only one copy of static variable is created, which is present in all instances)


QUESTION 5

A static method can call an instance method
Answer: True (A static method can call an instance method using the instance)

QUESTION 6
When a method receives an object as an argument, the method can change the values of its fields.
Answer: True(A reference to the address of the object is passed, and the changes are permanent)

QUESTION 9

Consider the following source code;

Stock stock1 = new Stock( "XIV", 119.5 );

Stock stock2 = stock1;

The variable stock2 points to a copy of the stock1 instance.
Answer: False(Variable stock2 points to same object as stock1)

QUESTION 10

You can't have an instance of a class to be a field of another class.
Answer: False(This is called an association)

Add a comment
Know the answer?
Add Answer to:
I need help with 3 - 6, 9 & 10 QUESTION 3 To call a static...
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
  • Need help finishing this code # Description : The Pet class contains fields for name, pet...

    Need help finishing this code # Description : The Pet class contains fields for name, pet # type,and age. The age field is the age now # or age of pet when it passed away. (These # are all dogs I have had.) There is a static or # class variable called number_pets that # tracks how many instances have been created. # The constructor will fill all fields and add # one to the number_pets variable. # The special...

  • I need help with my homework please. I should write this program in C++ language and...

    I need help with my homework please. I should write this program in C++ language and use Inventory.h file (header file), Inventory.cpp file (implementation file), and main.cpp file (main program). This is the program: Demonstrate the class in a driver program. Input validation, don’t accept negative values for item number, quantity, or cost. 6. Inventory Class Design an Inventory class that can hold information and calculate data for items ma retail store's inventory. The class should have the following private...

  • Java Questions A class must implement at least one interface. Question 1 options: True False Question...

    Java Questions A class must implement at least one interface. Question 1 options: True False Question 2 (1 point) Abstract methods can be called. Question 2 options: True False Question 3 (1 point) Constructors Question 3 options: Are inherited but cannot be accessed Are inherited and can be accessed Are accessible but are not inherited Are not inherited and cannot be accessed Question 4 (1 point) We can instantiate an object from an abstract class. Question 4 options: True False...

  • QUESTION 1 Each class must be declared in its own .java file True or False? QUESTION...

    QUESTION 1 Each class must be declared in its own .java file True or False? QUESTION 2 The keyword this must always be explicitly used when referring to an object's instance variables and methods from within one of its non-static methods. True or False? QUESTION 3 When used in a class' main method the this keyword references the object representing the class itself. True or False? QUESTION 4 Accessor methods that test whether a condition is true or false are...

  • Context of my question: I am reading C#. Trying to understand Static keyword. I understand that...

    Context of my question: I am reading C#. Trying to understand Static keyword. I understand that when Static is applied to a member of a class, it can only be modified by the class and not the class object references. I will take an example here. public class BluePrint {    public static string BluePrintCreatorName; } If I need to know the BluePrintCreator's Name, I can call BluePrint.BluePrintCreatorName; But if a house that is created from the blueprint wants to...

  • I am stuck on this question. Write the class, GeoLocation.java. You can refer to Name.java used...

    I am stuck on this question. Write the class, GeoLocation.java. You can refer to Name.java used in the lecture to complete the below exercises. Do the following: 1. Create two instance variables, lat and lng, both of which should be doubles. 2. Write the default constructor. 3. Write the non-default constructor. 4. Write 2 accessor methods, one for each instance variable. 5. Write 2 mutator methods, one for each instance variable. 6. Write a method that will return the location...

  • need help In this 4 question please and thank you Question 10 (2 points) (True/false) During...

    need help In this 4 question please and thank you Question 10 (2 points) (True/false) During the rising phase of the action potential, the charge inside of the axon changes from negative to positive (depolarizes) True False Question 11 (2 points) (True/false) During the rising phase of the action potential, potassium channels (gates) open and allow the cell to depolarize. True False An interneuron OA) Receives excitatory or inhibitory inputs from other neurons and then can activate or not activate...

  • ANY ANSWER IS MUCH APPRECIATED. THANK YOU!! QUESTION 1 ________ are useful for returning more than...

    ANY ANSWER IS MUCH APPRECIATED. THANK YOU!! QUESTION 1 ________ are useful for returning more than one value from a method. Default arguments Parameter lists Reference parameters Named arguments 1 points    QUESTION 2 When you call a ________ method, it executes its code and returns without passing any value back to the program statement that called it. void private terminal value-returning 1 points    QUESTION 3 You can pass string literals as arguments to methods containing  string parameters. True False...

  • Q1)(20p)Write a static member function called removeLongestRepeatingSegment that takes a String a...

    Q1)(20p)Write a static member function called removeLongestRepeatingSegment that takes a String argument. The method will return a new String by removing the logest segment that contains consequtively repeating characters. public static void main(String []args){ String s=”1111222223333311111111444455552222”; String res= removeLongestRepeatingSegment(s); will return “11112222233333444455552222” } public static String removeLongestRepeatingSegment(String s){ --------------- Q2)15p)Given a list of objects stored (in ascending order) in a sorted linked list, implement member method which performs search as efficiently as possible for an object based on a key....

  • i was able to make sense on the others but this two i need help Name:...

    i was able to make sense on the others but this two i need help Name: ImprovedQueue<T> Access Modifier: public Implements: QueueInterface<T> Instance variables Name: front Access modifier: private Data type: QueueNode<T> Constructors: Name: ImprovedQueue Access modifier: public Parameters: none (default constructor) Task: sets the value of front to null Methods Name: isEmpty Access modifier: public Parameters: none Return type: boolean Task: returns true if the front is equal to null; otherwise return false Name: dequeue                            Access modifier: public Parameters:...

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