Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Sample Question (Test for conceptual knowledge) 5.1: Categorize each identifier

ID: 3834147 • Letter: S

Question

Sample Question (Test for conceptual knowledge) 5.1: Categorize each identifier in the class listed below as an Instance Variable (IV), Class Variable (CV), Parameter (P), Local Variable (LV), Constructor (C), Instance Method (IM), or Class Method (CM).

public class Segment{

   private static int current = 10;

   private int id;

   private double x1, y1, x2, y2;

   public Segment( double a, double b ){       

      current++;              id = current;              double temp = a+b;       

      x1=a;       y1=b;       x2=temp;       y2=3;    }

   public void moveEnd( double c, double d ){

      x2=c;       y2=d;

   }

   public double flop(){       

      return x1+y2;    }

   public void smoosh( Segment other ){       

      x1=other.y2;              other.x1=y1;              y1 = other.x2;    }

   public String toString(){       

      return "[("+x1+","+y1+")("+x2+","+y2+")"+id+"]";    }

   public static void main(String[] args){

      Segment r = new Segment( 2, 5 );

      Segment s = new Segment( 4, 1 );

      System.out.println( r + " " + s );

      r.moveEnd( 8, 4 );

      s.moveEnd( 0, 0 );

      System.out.println( r + " " + s );

      System.out.println( r.flop() );

      s.smoosh(r);

      System.out.println( r + " " + s );

   }

}

Identifier

IV

CV

C

IM

CM

P

LV

current

id

x1

y1

x2

y2

Segment

a

b

temp

moveEnd

c

d

flop

smoosh

other

toString

main

args

r

s

Sample Question (Test for conceptual knowledge) 5.1: Categorize each identifier in the class listed below as an Instance Variable (IV), Class Variable (CV), Parameter (P), Local Variable (LV), Constructor (C), Instance Method (IM), or Class Method (CM).

public class Segment{

   private static int current = 10;

   private int id;

   private double x1, y1, x2, y2;

   public Segment( double a, double b ){       

      current++;              id = current;              double temp = a+b;       

      x1=a;       y1=b;       x2=temp;       y2=3;    }

   public void moveEnd( double c, double d ){

      x2=c;       y2=d;

   }

   public double flop(){       

      return x1+y2;    }

   public void smoosh( Segment other ){       

      x1=other.y2;              other.x1=y1;              y1 = other.x2;    }

   public String toString(){       

      return "[("+x1+","+y1+")("+x2+","+y2+")"+id+"]";    }

   public static void main(String[] args){

      Segment r = new Segment( 2, 5 );

      Segment s = new Segment( 4, 1 );

      System.out.println( r + " " + s );

      r.moveEnd( 8, 4 );

      s.moveEnd( 0, 0 );

      System.out.println( r + " " + s );

Explanation / Answer

Identifier

IV

CV

C

IM

CM

P

LV

current

right

id

right

x1

right

y1

right

x2

right

y2

right

Segment

right

a

right

b

right

temp

right

moveEnd

right

c

right

d

right

flop

smoosh

right

right

other

toString

right

main

right

args

right

r

right

s

right

Identifier

IV

CV

C

IM

CM

P

LV

current

right

id

right

x1

right

y1

right

x2

right

y2

right

Segment

right

a

right

b

right

temp

right

moveEnd

right

c

right

d

right

flop

smoosh

right

right

other

toString

right

main

right

args

right

r

right

s

right

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote