Tutorial 1 PDF

Title Tutorial 1
Author Dharvindaraj Jayaseelan
Course Programming
Institution Universiti Kebangsaan Malaysia
Pages 4
File Size 266.6 KB
File Type PDF
Total Downloads 8
Total Views 192

Summary

Tutorial 1...


Description

TK1114 COMPUTER PROGRAMMING

1

Tutorial 1 Introduction to Java & Turtle Graphics Section A: Introduction to Java 1. Java is an Operating system (True / False) 2. ________ contains predefined classes and interfaces for developing Java programs. 3. ________ consists of a set of separate programs for developing and testing Java programs, which invoked from a command line. 4. ________ provides an integrated development environment for rapidly developing Java programs. Editing, compiling, building, debugging, and online help are integrated in one graphical user interface. 5. How the main method in java should be written? 6. ___________ are used to document what a program is for and how a program is constructed.

7. Java compiler translates Java source code into _________. 8. Suppose you define a Java class as follows: public class Test { } In order to compile this program, the source code should be stored in a file named ____________. 9. The extension name of a Java bytecode file is _________ 10. If a program compiles fine, but it produces incorrect result, then what is happens to the program? 11. If you forget to put a closing quotation mark on a string, what kind of error will be raised? 12. What is the correct statements to display Welcome to Java on the console?

Sem1 2017-2018 session

TK1114 COMPUTER PROGRAMMING

2

Section B: Objects: Using, creating and communicating 1.

Explain the following MyTurtleApp.java. i. ii. iii. iv.

2.

What an object? Which is an object? How to declare an object? What is the output?

Explain the following MyTurtleApp2.java and what is the output?

Sem1 2017-2018 session

TK1114 COMPUTER PROGRAMMING

3

Section C: Write a Java Program Using Turtle Graphics Note: For this section, please refer to ‘Turtle Graphics Documentation’ to get a list of methods that you need to complete the task. Task 1: Write programs to draw the following figures

Create a new project and name it AxxxxxxLab1Task1 (Axxxxxx is your student number). In that project, add a new class called Rectangle containing the main method. a. b. c. d.

Create MWorld object named myWorld Set the title of MWorld frame to “Rectangle” Set the size of MWorld frame to width = 800 x height = 600 Create MTurtle named turtle. Note: MTurtle object live in MWorld.

e. Draw the shape. Task 2: Write programs to draw the following figures

Create a new project and name it AxxxxxxLab1Task2 (Axxxxxx is your student number). In that project, add a new class called Hexagon containing the main method. a. b. c. d. e.

Create MWorld object named myWorld Set the title of MWorld frame to “Hexagon” Set the size of MWorld frame. Create MTurtle named turtle. Draw the shape.

Sem1 2017-2018 session

TK1114 COMPUTER PROGRAMMING

4

Task 3: Write programs to draw the following figures

Task 4: Write programs to draw the following figures

Task 5: Sketch you own design and write a program to draw it.

Sem1 2017-2018 session...


Similar Free PDFs