Question

In: Computer Science

What is the main difference between arrays and ArrayLists? Arrays can be resized, ArrayLists cannot. ArrayLists...

  1. What is the main difference between arrays and ArrayLists?
    1. Arrays can be resized, ArrayLists cannot.
    2. ArrayLists can be resized, Arrays cannot.
    3. Arrays can hold more information than ArrayLists
    4. ArrayLists can hold more information than Arrays

  1. What method is used to add a new element to the end an ArrayList?
    1. .add
    2. .new
    3. .insert
    4. .put

  1. What is the proper syntax for accessing the third element of an ArrayList called Books?
    1. Books.elementAt(3);
    2. Books.elementAt(2);
    3. Books[3];
    4. Books[2];

  1. What is overloading?
    1. Having a method in a child class which replaces a method of the same name in the parent class
    2. Having two or more method with the same name but different parameters
    3. Writing more methods than a class can support
    4. Writing more child classes than a parent class can support

  1. What is overriding?
    1. Having a method in a child class which replaces a method of the same name in the parent class
    2. Having two or more method with the same name but different parameters
    3. Writing more methods than a class can support
    4. Writing more child classes than a parent class can support

  1. When does a constructor run?
    1. When the program ends
    2. When the program starts
    3. When an object is released from memory
    4. When an object is created.

  1. Which of the following is the proper syntax for having a class named Child inherit from a class named Parent?
    1. public class Child extends Parent
    2. public class Child implements Parent
    3. public class Child : Parent
    4. public class Child -> Parent

  1. What is a virtual method?
    1. A method that can be overridden but does not have to be overridden
    2. A method with no definition that must be overridden
    3. A method that cannot be overridden
    4. Virtual methods are not supported by C#

  1. What is an abstract method?
    1. A method that can be overridden but does not have to be overridden
    2. A method with no definition that must be overridden
    3. A method that cannot be overridden
    4. Abstract methods are not supported by C#

  1. True/False. An abstract class cannot be instantiated.
    1. True
    2. False

  1. Which of the following is valid:
    1. ParentClass myObject = new ChildClass();
    2. ChildClass myObject = new ParentClass();
    3. new ParentClass myObject = ChildClass();
    4. new ChildClass myObject = ParentClass();

  1. MessageBox._______ causes a popup to display on the screen
    1. popup
    2. display
    3. show
    4. dialog

  1. The _________ property of the textbox, label, and many other controls determines what is currently written in the control.
    1. label
    2. writing
    3. text
    4. name
  1. Complete the following code:

foreach(int i ______ intArr)

    1. in
    2. on
    3. under
    4. over
  1. A private variable is
  1. Only in a method
  2. Only accessible from a method methods
  3. Part of a class, not an instance.
  4. Part of an instance, Not a class.
  1. The static Keyword
  1. Allows access to a method without an instantiated object
  2. Allows instance variables to be accessed from within a static method
  3. Only has one copy of itself during runtime
  4. Both 1 & 3
  5. All of the above.
  1. Properties are different than fields because:
  1. Fields are static
  2. Properties are static
  3. Properties can perform actions such as method calls
  4. Fields can perform actions such as method calls.
  1. An object is a(n) ____________ of a class.
    1. figment
    2. institution
    3. instantiation
    4. child
  1. Class fields are created with the ____________ modifier by default.
    1. Public
    2. Private
    3. Internal
    4. Caustic
  2. The thisreference is (Circle all that apply)
    1. Confusing
    2. Straight-Forward
    3. Implied in certain circumstances
    4. Better than a sharp stick in the eye.

Solutions

Expert Solution

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

Question 1:

Answer :b.ArrayLists can be resized, Arrays cannot.

Explanation :

  • Array can not resized , array size need to be given while declaring array this means array is static in nature
  • ArrayList can be resized hence arrayList is dynamic in nature.

*************************:

Question 2:

Answer :a.add

Explanation :ArrayList add() method is used to add the element in the arraylist.

*************************:

Question 3:

Answer :b.Books[2];

Explanation :Books[2]; will get the third element from the array list.

*************************:

Question 4:

Answer :b.Having two or more method with the same name but different parameters

Explanation :

  • Overloading is having the more than one method in the class with name name but with different parameters.
  • Overloading happens in a single class.
  • Overloading means polymorphism.

*************************:

Question 5:

Answer :a.Having a method in a child class which replaces a method of the same name in the parent class

Explanation :

  • Overriding happens in the inheritance means base class method is override by child class.

*************************:

Question 6:

Answer :d.When an object is created.

Explanation :Constructor is called or run when object of the class is created.

*************************:

Question 7:

Answer :c.public class Child : Parent

Explanation :Inheritance in C# is using colon (:) operator.

*************************:

Question 8:

Answer :a.A method that can be overridden but does not have to be overridden

Explanation :A method that can be overridden but does not have to be overridden

*************************:

Question 9:

Answer :b.A method with no definition that must be overridden

Explanation :Abstract method is a method with definition and declared with abstract keyword.

*************************:

Question 10:

Answer :a.True

Explanation :Abstract class is class which is used as base class.Object of abstract class can not be creaeted.

*************************:

Question 11:

Answer :b.ChildClass myObject = new ParentClass();

Explanation :Child class can access the properties and methods from base class.

*************************:

Question 12:

Answer :.c.show

Explanation :MessageBox.show() causes a popup to display on the screen

*************************:

Question 13:

Answer :c.text

Explanation :text property of controls is used to set text.

*************************:

Question 14:

Answer :a.in

Explanation :foreach(int i in intArr)

*************************:

Question 15:

Answer :c.Part of a class, not an instance.

Explanation :Private variables can not be accessed using object of a class.

*************************

Question 16:

Answer :e.All of the above.

Explanation :

  • Static variable can be shared with all the objects
  • Static method can be accessed without creating object of class.

*************************

Question 17:

Answer :c.Properties can perform actions such as method calls

Explanation :Properties can have getter and setter methods.

*************************

Question 18:

Answer :c.instantiation

Explanation :Object is an instance of a class.

*************************

Question 19:

Answer :b.Private

Explanation :When no access specifier is specified then by default class fields are Private.

*************************

Question 20:

Answer :c.Implied in certain circumstances

Explanation :this keyword is used to refer to the current class.

*************************:

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.


Related Solutions

Explain the difference between Arrays and ArrayList. What are the limitation of arrays? How many primitive...
Explain the difference between Arrays and ArrayList. What are the limitation of arrays? How many primitive data types Java have? Please list them out and list the corresponding wrapper classes for each type. What is the different between String class and StringBuilder class?
What is the main difference between notes payable and bonds payable? What is the main difference...
What is the main difference between notes payable and bonds payable? What is the main difference between a bond and a share of stock? What does it mean to issue bonds at Par? Discount? Premium? What is the contract rate and the market rate for bonds? How do you compute total bond interest expense when a bond is sold at a discount? Explain your answer. How do you compute bond interest expense when a bond is sold at a premium?...
What is the main difference between numeric variable and categorical variable; the main difference between ordinal...
What is the main difference between numeric variable and categorical variable; the main difference between ordinal variable and nominal variable; the main difference between ratio variable and interval variable?
difference between COOL lamguage and assembly language arrays ?
difference between COOL lamguage and assembly language arrays ?
What is the main difference between polygene inheritance and heritability?
What is the main difference between polygene inheritance and heritability?
What are the main difference between plant and animal cells?
What are the main difference between plant and animal cells?
a)(5%) Briefly explain the difference between hardness and hardenability.b)(5%) What is the main difference between eutectic,...
a)(5%) Briefly explain the difference between hardness and hardenability.b)(5%) What is the main difference between eutectic, eutectoid and peritectic reactions? c)(10%) A cylindrical piece of 5140 steel heated to γ region and OQ. If the hardness at the surface must be ≥ 35HRC, what is the maximum allowable dia.? Explain.
What is the main difference between the “Protestant Ethic” and the “Spirit of Capitalism”?
What is the main difference between the “Protestant Ethic” and the “Spirit of Capitalism”?
What is the main difference between semaphore and a CV? A semaphore and a lock?
What is the main difference between semaphore and a CV? A semaphore and a lock?
a- What is the main difference between the “net product” of the physiocrats and the concept...
a- What is the main difference between the “net product” of the physiocrats and the concept of value in Smith and Ricardo? b- How did Marx’s times help him develop his own specific labor theory of value? c- How does an individualist (selfish) conception of human nature affect an economic system of thought?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT