public class X{private int x,y; public void m1(boolean b) {x<<=1;if(b)x++;y++;}public Boolean m2 () {if(m6 ( )) return null;return x%2!=0;}public Boolean m3(){Boolean z=m2 ();if(z!=null){x>>>=1;y--;}return z;}public void m4(){x=y=0;}public int m5 () {return y;}public boolean m6 () {return y==0;}} w www wm

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Java help !!! Please help me with my questions. Provide detailed answers. Thanks. Should mention that the class is called X and this is the way the code was provided. I am intermediate level at java currently studying year 1 comp sci. thanks again

public class X{private int x,y; public
void m1(boolean
b) {x<<=1;if(b)x++;y++;}public Boolean
m2 () {if(m6 ( )) return null;return
x%2!=0;}public Boolean m3(){Boolean
z=m2 ();if(z!=null){x>>>=1;y--;}return
z;}public void m4(){x=y=0;}public int
m5 () {return y;}public boolean m6 () {return
y==0;}}
Transcribed Image Text:public class X{private int x,y; public void m1(boolean b) {x<<=1;if(b)x++;y++;}public Boolean m2 () {if(m6 ( )) return null;return x%2!=0;}public Boolean m3(){Boolean z=m2 ();if(z!=null){x>>>=1;y--;}return z;}public void m4(){x=y=0;}public int m5 () {return y;}public boolean m6 () {return y==0;}}
Advanced: Legacy code
One of the developers on your team has gone into retirement and the job of maintaining their code
has been dumped on you. In order to add a new feature, you must understand how the existing code
works. The class X.java (in Assignment2.zip) is particularly obscure. Your predecessor seems to
have been obsessed with efficiency and has no concept of code quality or documentation. All you
can tell from context is that it must be some kind of data structure. You now have to look at the code
to work out what it does. Hint: Look up bitwise operators and bit shifting.
For each method in X.java, do the following:
State what the method does.
Give it a more descriptive name.
Explain in detail how the code works (not required for methods m5 and m6).
Finally, answer the following questions:
What kind of data structure is this i.e. what would be a better name for class X?
What are the advantages and disadvantages of the chosen data representation?
What is categorically wrong with X.java?
What aspect of the code can be justified and under which circumstances?
Transcribed Image Text:Advanced: Legacy code One of the developers on your team has gone into retirement and the job of maintaining their code has been dumped on you. In order to add a new feature, you must understand how the existing code works. The class X.java (in Assignment2.zip) is particularly obscure. Your predecessor seems to have been obsessed with efficiency and has no concept of code quality or documentation. All you can tell from context is that it must be some kind of data structure. You now have to look at the code to work out what it does. Hint: Look up bitwise operators and bit shifting. For each method in X.java, do the following: State what the method does. Give it a more descriptive name. Explain in detail how the code works (not required for methods m5 and m6). Finally, answer the following questions: What kind of data structure is this i.e. what would be a better name for class X? What are the advantages and disadvantages of the chosen data representation? What is categorically wrong with X.java? What aspect of the code can be justified and under which circumstances?
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY