Preview

Java 01

Satisfactory Essays
Open Document
Open Document
914 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Java 01
TMA 01

Question 1

i)

A)

Reciever = Kermitt
Message = sameColourAs(gribbit)
Message send = kermit.sameColourAs(gribbit)
Argument = gribbitt

B)

kermit.right(); kermit.getPosition(); gribbit.brown(); gribbit.getColour(); C)

1, None
2, Right
3, None
4, None
5, Brown
6, None

ii)

A)

Two frog objects exist after the code has been executed. The two variables that the objects refer to are croaker and hoppy. The varialble of croaker is created in statement 2 and the variable of Kermit is changed to hoppy in statement 5.

B)

Kermit = Purple
Statement 3 initially changes the colour of Kermit to blue but when the variable is renamed in statement 5 it changes the colour to purple.
Croaker = Yellow
Statement 4 sets the colour of the object to yellow.
Hoppy = Purple
Statement 6 sets the object colour to purple.

C)

Constructor = new frog
Variable = Kermit
Type = Frog
Operator = equals sign

ii)

Statement 1 would cause and error as it contains the wrong type as it is looking for hoverfrog but can only find frog. Statement 2 is ok as the variable has been renamed as Hoverfrog.

Question 2
i)

/** * Sets the relevant spots in there correct locations. */ public void reset() {

this.getTopLeftSpot().setXPos(3); this.getTopLeftSpot().setYPos(3); this.getTopMiddleSpot().setXPos(25); this.getTopMiddleSpot().setYPos(3); this.getTopRightSpot().setXPos(48); this.getTopRightSpot().setYPos(3); this.getMiddleSpot().setXPos(25); this.getMiddleSpot().setYPos(25); this.getBottomMiddleSpot().setXPos(25); this.getBottomMiddleSpot().setYPos(48); this.getBottomRightSpot().setXPos (48); this.getBottomRightSpot().setYPos (48); this.getBottomMiddleSpot().setXPos(25);

You May Also Find These Documents Helpful

  • Satisfactory Essays

    Cja324

    • 253 Words
    • 2 Pages

    Officers Nixon and Rook decided to arrest the husband for driving under the influence. He is taken to the station for processing. During processing, the husband is visibly agitated. He keeps mumbling to himself and rocking back and forth in his chair. His wife comes to the station and reports that her husband had some bad experiences while in Somalia. She requests that he be allowed to return home with her after processing. The police officers, already at the end of their shift, readily agree.…

    • 253 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    PT1420 Chapter 3 Review

    • 1062 Words
    • 8 Pages

    3. Write assignment statements that perform the following operations with the variables a, b, and c.…

    • 1062 Words
    • 8 Pages
    Satisfactory Essays
  • Satisfactory Essays

    4.) Write assignment statements that perform the following operations with the variables a, b, and c:…

    • 453 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    unit 7 assignment 1

    • 431 Words
    • 2 Pages

    1. Why should you indent the statements in the body of a loop? You visually set them apart from the surrounding code.…

    • 431 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Cj328

    • 474 Words
    • 2 Pages

    When I was dusting my apartment for prints I found about 5 different prints and 2 partial prints. I found one partial print on the glass on my coffee table in the living room and one partial print on the night stand in my room. I found 2 prints on the glass on the sliding door to my patio and 1 print on the mirror in the master bathroom, 1 print on the back of a CD found on the end table in the living room and 1 print on the dining room table in the. I went to JoAnn Fabrics to get a Slinky Science fingerprint science kit so I could use the powder and the feather from the box. The powder came in a bottle so it made it really hard to get prints and I actually had my boyfriend put prints on the things I listed so I could use the powder and the powder was also white and made it hard to see. When I used the feather it would smudge the print and I would have to try and use it a different direction. If I were to side to side with the feather it would smudge the print but if I would go up and down it would push the powder away so I was able to see the print better but not clearly. I did not find any prints in my apartment due to my boyfriend cleaning everything. This is why I only find the prints I did because I asked him to put the prints there. Yes I could tell the difference between the prints if I were to put my print right next to it. My finger print has loops and my boyfriend’s prints have tent arches on them. Some of the surfaces that I would think I would find prints on are door knobs, TV, the handle on a microwave, the keys to the car, the thermostat and light switches, books, cell phones and you could also get prints off of duct tape and the door handles of a car that has metal handles and you can get prints off of garbage bags also and DVD cases. When I was doing this assignment I found that trying to get a print from surfaces…

    • 474 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Pt1420 Assignment

    • 1058 Words
    • 5 Pages

    1) Initialization: the variable is initialized 2) Test: the loop tests the variable by comparing it to the maximum value 3) Increment: to increase the value during each iteration the loop increments the counter variable by adding 1 to it.…

    • 1058 Words
    • 5 Pages
    Satisfactory Essays
  • Powerful Essays

    SampleExam

    • 1710 Words
    • 14 Pages

    if you have a gif image it is better not to keep saving it as a gif…

    • 1710 Words
    • 14 Pages
    Powerful Essays
  • Satisfactory Essays

    unit 3

    • 313 Words
    • 2 Pages

    4. Assume the variables result, w, x, y , and z are integers, and that w=5, x=4, y=8, and z=2. What value will be stored in result in each of the following statements?…

    • 313 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    I Like to 1321

    • 459 Words
    • 2 Pages

    statement. Also included is a for loop (repetition statement). Pay close attention to these as you…

    • 459 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    //casestudy 1 the drunken cockroach/*start of the program*/#include<stdio.h>#include<conio.h>#include<stdlib.h>#include<dos.h>void main(){int iteration,sizerow,sizecol,imove[8],jmove[8],k,ibug,jbug,a,b,legal=0,boundaryrow,boundarycol,move=0,count[40][40]={0};char tile[40][40];clrscr();printf("The Drunken Cockroach Simulator!\n");printf("Note:\nSometimes this cockroach steps on the already stepped tiles because its drunken");printf("\n'S' - stands for the starting point \n'C' - stands for the stepped tiles \n'Q' - stands for unwalkable tiles");printf("\nInput the size of the room you want (row,column): ");scanf("%d,%d",&sizerow,&sizecol);printf("Input the cockroach's starting point (row,column): ");scanf("%d,%d",&jbug,&ibug);printf("Input…

    • 93 Words
    • 1 Page
    Satisfactory Essays
  • Good Essays

    Variables: This program gets a number from the user. We need a variable to hold the number. We need to print the numbers from 1 up to the user's number. We need a second variable for this.…

    • 789 Words
    • 4 Pages
    Good Essays
  • Powerful Essays

    jrotc let1

    • 7101 Words
    • 29 Pages

    1 If someone asked you about what you expect to get out of Army JROTC, which one of the following responses would you use to best inform them about the mission and purpose of JROTC?…

    • 7101 Words
    • 29 Pages
    Powerful Essays
  • Good Essays

    J2Me Coding

    • 4143 Words
    • 17 Pages

    1 import javax.microedition.midlet. *; import javax.microedition.lcdui. *; public class Calculator extends MIDlet implements CommandListener { private Display dsp; private Form fm; private TextField tf1,tf2; private StringItem sitres; private ChoiceGroup cg; private Command cmdq,cmdcalc,cmddate; public Calculator() { fm=new Form("Calculations"); tf1= new TextField("Number1:","",3,TextField. NUMERIC); tf2= new TextField("Number2:","",3,TextField. NUMERIC); sitres=new StringItem("Result",""); cg=new ChoiceGroup("Operation",ChoiceGroup.EXCLUSIVE); cg.append("Add",null); cg.append("Subtract",null); cg.append("Mul",null); cg.append("Div",null); cmdq=new Command("Quit",Command.…

    • 4143 Words
    • 17 Pages
    Good Essays
  • Satisfactory Essays

    Core Java Vol Ii 8th Ed.

    • 21466 Words
    • 86 Pages

    Core Java Volume II-Advanced Features, Eighth Edition - Graphically Rich Book ....................... 1 Table of Contents ................................................................................................................................................................................. 2 Copyright ..................................................................................................................................................................................................... 5 Preface .......................................................................................................................................................................................................... 7 Acknowledgments ............................................................................................................................................................................. 10 Chapter 1. Streams and Files .................................................................................................................................................. 11 Streams ................................................................................................................................................................................................ 22 Text Input and Output .................................................................................................................................................................... 33 Reading and Writing Binary Data ............................................................................................................................................. 43 ZIP Archives ....................................................................................................................................................................................... 51 Object Streams and Serialization…

    • 21466 Words
    • 86 Pages
    Satisfactory Essays
  • Powerful Essays

    Netbeans

    • 2569 Words
    • 11 Pages

    What Is a Rich Client? In a client server architecture the term rich client is used for clients where the data processing occurs mainly on the client side. The client also provides the graphical user interface (GUI). Often rich clients are applications that are extendable via plug-ins and modules. In this way, rich clients are able to solve more than one problem. Rich clients are typically developed on top of a framework. A framework offers a basic starting point on top of which the user can assemble logically related parts of the application, which are called modules. An overview of the characteristics of a rich client: ✔ Flexible and modular application architecture ✔ Platform independence ✔ Adaptability to the end user ✔ Ability to work online as well as offline ✔ Simplified distribution to the end user ✔ Simplified updating of the client What Is a Rich Client Platform? A rich client platform is an application life cycle environment, a basis for desktop applications. Most desktop applications have similar features, such as ✔ menus ✔ Toolbars ✔ status bar ✔ progress visualizations ✔ data display ✔ customization setting ✔ Saving and loading user-specific data and configurations ✔ Splash screens ✔ about boxes ✔ internationalization ✔ help systems etc ….... The most important aspect of a rich client platform is its architecture. Applications based on rich client platforms are written in the form of modules , within which logically coherent parts of an application are isolated . A rich client platform also frees the developer from being concerned with tasks that have little to do with the application’s business logic. Advantages of a Rich Client Platform ✔ ✔ Modularity :- provides high degree of robustness and end user value Reduction of Development Time →Through the re-usability of many predefined components, developers are able to concentrate very closely on the business logic of the application in question. →It provides a multitude of application programming…

    • 2569 Words
    • 11 Pages
    Powerful Essays

Related Topics