Skip to content
Past Exams

IST242 Computer Science Midterm Exam With Answers (65 Solved Questions)

Familiarize yourself with exam difficulty levels using IST242 Computer Science Midterm Exam With Answers, packed with past exams.

Preview 11 of 36 pages

See the first 11 pages exactly as they appear in the document.

  1. Page 1
    Read page 1 as text

    MIDTERM EXAM (Concepts) Due Feb 28 at 11:59pm Points 65 Questions 65 Available Feb 27 at 12pm Feb 28 at 11:59pm 1 day Time Limit 80 Minutes This quiz was locked Feb 28 at 11:59pm. Aempt History Attempt Time Score LATEST Attempt 1 45 minutes 65 out of 65 Score for this quiz: 65 out of 65 Submitted Feb 27 at 1pm This attempt took 45 minutes. 1 / 1 pts Question 1 Which of the following are considered members of a class? Private instance variables and methods. All instance variables and methods. Correct! Correct! Nonstatic instance variables and methods. Public instance variables and methods. 1 / 1 pts Question 2 Given the following class definition, which of the following are NOT considered part of the class’s public interface? public class Motorcycle

  2. Page 2
  3. Page 3
    Read page 3 as text

    { public static final int WHEEL_COUNT = 2; private int rpmRating; public void updatePrice(double increase) {…} private String designCode() {…} } rpmRating and designCode Correct! Correct! WHEEL_COUNT and designCode WHEEL_COUNT and updatePrice updatePrice and designCode 1 / 1 pts Question 3 The public constructors and methods of a class form the public _____ of the class. interface Correct! Correct! initialization implementation encapsulation 1 / 1 pts Question 4 Which of the following statements about classes is correct?

  4. Page 4
    Read page 4 as text

    A class is an object that can be manipulated by a program. A class describes a set of objects with the same behavior. Correct! Correct! Class is another name for a method. A class can contain only methods. 1 / 1 pts Question 5 You have created a Motorcycle class which has a constructor with no parameters. Which of the following statements will construct an object of this class? Motorcycle myBike; Motorcycle myBike = new Motorcycle(); Correct! Correct! myBike.new(Motorcycle); Motorcycle.new(myBike); 1 / 1 pts Question 6 Data required for an object's use are stored in ____. local variables instance variables Correct! Correct! parameters methods

  5. Page 5
    Read page 5 as text

    1 / 1 pts Question 7 An instance variable declaration consists of ____. the return type, the name of the method, and a list of the parameters (if any). an access specifier, the type of the instance variable, and the name of the instance variable. Correct! Correct! an access specifier, a list of the parameters (if any), and the body of the method. the type of the instance variable, an access specifier, a list of the parameters (if any), and the body of the method. 1 / 1 pts Question 8 Which of the following statements is true regarding classes? Each object of a class has a separate copy of each instance variable. Correct! Correct! All objects created from a class share a single set of instance variables. Private instance variables can be accessed by any user of the object. Public instance variables can be accessed only by the object itself.

  6. Page 6
    Read page 6 as text

    1 / 1 pts Question 9 A method in a class that returns information about an object but does not change the object is called a/an ____ method. mutator accessor Correct! Correct! void constructor 1 / 1 pts Question 10 Consider the following code snippet: public class Vehicle { . . . public void setVehicleAttributes(String attributes) {. . . } public String getVehicleAtrributes() {. . . } public String getModelName() {. . . } } Assuming that the names of the methods reflect their action, which of the following statements about this class is correct? setVehicleAttributes is an accessor method. setVehicleAttributes is a mutator method. Correct! Correct!

  7. Page 7
    Read page 7 as text

    getVehicleAttributes is a mutator method. getModelName is a mutator method. 1 / 1 pts Question 11 Which type of method modifies the object on which it is invoked? Constructor method. Static method. Accessor method. Mutator method. Correct! Correct! 1 / 1 pts Question 12 The utility that formats program comments into a set of documents that you can view in a Web browser is called ____. javadoc Correct! Correct! javac javad java 1 / 1 pts Question 13

  8. Page 8
    Read page 8 as text

    Private instance variables ___. can only be accessed by methods of a different class can only be accessed by methods of the same class Correct! Correct! cannot be accessed by methods of the same class can only be accessed by the constructor of the class 1 / 1 pts Question 14 Which of the following declares a sideLength instance variable for a Square class that stores an integer value? private integer sideLength; private int sideLength; Correct! Correct! public integer sideLength; public int sideLength; 1 / 1 pts Question 15 You should declare all instance variables as ___. protected class public

  9. Page 9
    Read page 9 as text

    private Correct! Correct! 1 / 1 pts Question 16 Which of the following statements about instance methods is correct? An instance method should always be declared as public. An instance method should always be declared as private. An instance method should be declared as public only if it is a helper method. An instance method should be declared as private only if it is a helper method. Correct! Correct! 1 / 1 pts Question 17 Consider the following code snippet: public int getCoinValue(String coinName) { . . . } Which of the following statements is correct? coinName is an implicit parameter. coinName is an explicit parameter. Correct! Correct! coinName is the object on which this method is invoked. coinName is an instance variable.

  10. Page 10
    Read page 10 as text

    1 / 1 pts Question 18 Complete the following code snippet to create a constructor that will initialize the class instance variables shown using data provided by the program which is creating an object from this class. public class Employee { private String empID; private boolean hourly; _______________________ { . . . } } Which of the following statements can be used to create an object of type Employee ? public Employee(String employeeID, boolean isHourly) Correct! Correct! public Employee(employeeID, isHourly) public Employee(empID, Hourly) public Employee() 1 / 1 pts Question 19 Which statement calls a constructor with no construction parameters? Circle c = new Circle(); Correct! Correct! Circle c = new Circle; Circle c = Circle()

  11. Page 11
    Read page 11 as text

    A call to a constructor must have construction parameters. 1 / 1 pts Question 20 A constructor is invoked when ___ to create an object. the class keyword is used the class is defined as public the new keyword is used Correct! Correct! the class is defined as private 1 / 1 pts Question 21 You have created a Rocket class which has a constructor with no parameters. Which of the following statements will construct an object of this class? Rocket myRocket; Rocket myRocket = new Rocket(); Correct! Correct! myRocket.new(Rocket); Rocket.new(myRocket); 1 / 1 pts Question 22

25 more pages in the full document

Unlock it once and it stays in your library, ready to chat with or turn into flashcards.

Unlock the full document
See all

Study this document with CramX

Once it is in your library, every tool can work from it.