Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

QUESTION 1 The following dropStudent method from listing 10.6 contains two errors. What are they? 01 public void dropStudent(String student ) { 02 int locationToZap

QUESTION 1

  1. The following dropStudent method from listing 10.6 contains two errors. What are they?

    01 public void dropStudent(String student) {

    02 int locationToZap = -1;

    03 int currLoc = 0;

    04 for (currLoc = 0; currLoc < numberOfStudents && locationToZap == -1; currLoc++) {

    05 if (students[currLoc] == student) {

    06 locationToZap = currLoc;

    07 }

    08 }

    09 if (locationToZap == -1) return;

    10 for (currLoc = locationToZap; currLoc < numberOfStudents; currLoc++) {

    11 students[currLoc] = students[currLoc + 1];

    12 }

    13 numberOfStudents--;

    14 }

     

    line 10 should have numberOfStudents - 1 in the condition

    line 04 should use numberOfStudents - 1 in the condition

    line 09 should use != as its conditional relation

    line 13 should be moved to the first line of the method

    line 04 should omit the locationToZap == -1 in the condition

    line 03 should be deleted and line 04 changed to be "for (int currLoc....."

    line 13 should be deleted

    line 05 should use .equals to compare string objects

1 points

QUESTION 2

  1. Encapsulation lets the user of our class know exactly how we implemented our function.

    True

    False

1 points

QUESTION 3

  1. Jack is assigned to implement a class that has a published specification. He needed to add a parameter to one of its methods. What best describes this situation? (Note that this is a multiple answer question.)

    Other programmers can easily add the parameter when they wish to use the updated method.

    Jack's change may cause other programs to fail to compile.

    Jack may have found a bug in the published specification.

    Jack has violated the published contract.

    Jack should change the published specification.

1 points

QUESTION 4

  1. Integer is a __________ for int.

    composition

    conversion

    association

    wrapper

1 points

QUESTION 5

  1. Which of the following classes exhibit encapsulation?

     public class Sophie 
     { 
     private String name; 
     } 
     public class Sally 
     { 
     public String name; 
     } 
     
    Only Sally exhibits encapsulation
    Neither Sophie nor Sally exhibit encapsulation

    Only Sophie exhibits encapsulation

    Both Sophie and Sally exhibit encapsulation

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data With Hadoop MapReduce A Classroom Approach

Authors: Rathinaraja Jeyaraj ,Ganeshkumar Pugalendhi ,Anand Paul

1st Edition

1774634848, 978-1774634844

More Books

Students also viewed these Databases questions