Exam 5: Writing Classes

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

A _______________ variable is shared among all instances of a class.

(Multiple Choice)
4.9/5
(37)

When applied to instance variables, the ________________ visibility modifier enforces encapsulation.

(Multiple Choice)
4.9/5
(45)

Write a method called threeOfAKind that takes in three integer parameters and returns true if all three of them are the same, false otherwise.

(Short Answer)
4.9/5
(43)

If a service is so complex that it cannot be reasonably be implemented using one method, it is often helpful to decompose it to make use of ________________ support methods.

(Multiple Choice)
4.8/5
(44)

Variables that are declared as static are shared among all instances of a class.

(True/False)
5.0/5
(46)

The ________________ reference always refers to the currently executing object.

(Multiple Choice)
4.8/5
(35)

A ________________ diagram helps us visualize the contents of and relationships among the classes of a program.

(Multiple Choice)
4.9/5
(27)

Explain why a static method cannot refer to an instance variable.

(Essay)
4.8/5
(33)

A programmer is required to define a constructor for every class.

(True/False)
4.7/5
(36)

Explain the difference between actual parameters and formal parameters.

(Essay)
4.8/5
(39)

Write a method that prints your name, age, and major. The method should accept no parameters and return no value.

(Short Answer)
4.8/5
(32)

Write a method called containsPair that takes in three integer parameters and returns true if any two of the input parameters are the same.

(Short Answer)
4.7/5
(43)

Which of the following method headers is most likely a header for a mutator method?

(Multiple Choice)
4.9/5
(39)

A(n) ___________________ object is one that is made up, at least in part, of other objects.

(Multiple Choice)
4.9/5
(30)

A return statement is not required at the end of every method.

(True/False)
4.9/5
(35)

Write a method called square that takes in an integer value and returns the integer squared. Your method should use the Math.pow() method.

(Short Answer)
5.0/5
(34)

Write a method called isPalindrome that accepts a String as a parameter and returns true if the String is a palindrome, and false otherwise. You may assume that the entered String consists entirely of lowercase letters (meaning it contains no numbers, spaces, punctuation, etc). Hint: write code that creates a new string that is the original string reversed, and then check to see if the two strings are equal.

(Short Answer)
4.8/5
(37)

A main method can only access static or local variables.

(True/False)
4.9/5
(37)

The versions of an overloaded method are distinguished by ___________________________.

(Multiple Choice)
4.8/5
(33)

Aggregation is sometimes described as a has-a relationship.

(True/False)
4.7/5
(36)
Showing 21 - 40 of 40
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)