Pre-ap computer Science 1 Semester 1 Examination Review



Download 211.14 Kb.
Date09.01.2017
Size211.14 Kb.
#8169

Pre-AP Computer Science 1

Semester 1 Examination Review

Scratch

ExpoJava Ch. 2 - 4

Alice - Chapters 1 – 2

Question 1 xx

What is output by the code to the right?


set a to 99

if a > 99

say "abc"

say "def"




Question 2 xx

What is output by the code to the right?



set b to 100

if b > 99

say "abc"

say "def"


Question 3 xx

What is output by the code to the right?



set c to 100

if c = 100

say "wow"

if c > 95

say "def"




Question 4 xx

What is output by the code to the right?



set d to 100

set e to 88

if d > 90

say "abc"

if e < 95

say "def"


Question 5 xx

What is output by the code to the right?



set f to 100

set g to 88

if f > 99

say "abc"

if g > 95

say "def"


Question 6 xx

What is output by the code to the right?



set h to 100

set i to 88

if h > 90

if i > 95

say "def"

if h > 95

say "ghi"






Question 7 xx

What is output by the code to the right?



set a to 75

repeat 5

change a by -5

say a


Question 8 xx

What is output by the code to the right?



set a to 63

repeat 4

change a by -7

say a


Question 9 xx

What is output by the code to the right?



set a to 100

repeat 3

change a by -5

say a


Question 10 xx

What is output by the code to the right?



set a to 60

repeat 2

change a by 10

say a


Question 11 xx

What is output by the code to the right?



set a to 50

repeat 6

change a by 3

say a


Question 12 xx

What is output by the code to the right?



set a to 0

repeat 7

change a by 2

say a


Question 13 xx

What is output by the code to the right?



set a to -14

repeat 3

change a by 12

say a


Question 14 xx

What is output by the code to the right?



set c to 1

repeat until c > 49

change c by 8

say c


Question 15 xx

What is output by the code to the right?



set c to 5

repeat until c > 60
change c by 10

say c






Question 16 xx

What is output by the code to the right?



set c to 30

repeat until c < 10
change c by -5

say c



Question 17 xx

What is output by the code to the right?



set d to 10

repeat until d > 71
change d by 6

say d



Question 18 xx

What is output by the code to the right?



set d to 32

repeat until d > 50
change d by 4

say d



Question 19 xx

What is output by the code to the right?



set d to 100

repeat until d < 71
change d by -7

say d



Question 20 xx

What is output by the code to the right?



set e to 90

repeat until e < 20

if e > 50


change e by -15

else


change e by -10

say e



Question 21 xx

What is output by the code to the right?



set e to 150

set count to 0

repeat until e < 75

if e > 100
change e by -20

else


change e by -5

change count by 1

say count



Question 22 xx

What is output by the code to the right?



set e to 0

set cnt to 0

repeat until e > 100

if e < 50
change e by 15

else


change e by 9

change count by 1

say count





Question 23 xx

What is output by the code to the right?



set f to 1


set g to 0
repeat until f > 20

change g by f

change f by 4

say g



Question 24 xx

What is output by the code to the right?



set f to 1


set g to 0
repeat until f > 16

change g by f

change f by 7

say g



Question 25 xx

What is output by the code to the right?



set f to 45


set g to 0
repeat until f < 30

change g by f

change f by -7

say g



Question 26 xx

What is output by the code to the right?



set list as empty

set a to 3

repeat 2


add a to list

say list



Question 27 xx

What is output by the code to the right?



set list as empty

set a to 2

repeat 6


add a to list

say list



Question 28 xx

What is output by the code to the right?



set list as empty

set b to 2

repeat 4


change b by 3

add b to list

say list


Question 29 xx

What is output by the code to the right?



set list as empty

set b to 5

repeat 5


change b by 5

add b to list

say list




Introduction to Computer Science
The secret of computer information storage and calculation is the binary system. Information is stored in a computer with combinations of base-2 ones and zeroes. Individual binary digits (bits) store a one or a zero. A one means true and a zero means false. A set of eight bits forms one byte.
A byte can store one character in memory with ASCII, which allows 256 different characters. The newer, international Unicode stores one character in two bytes for a total of 65536 different characters.
Operating systems change frequently, or at least operating system versions change to a new-and-improved model about every two or three years. A solid knowledge of your computer's operating system is vital. Writing a computer program requires knowledge of editing text, saving and loading files and moving around the hard drive's directory system efficiently.
Sun Microsystems created Java to be a programming language that is portable on many computer platforms, a so-called platform-independent language. They also wanted the language to be compatible with web page development.
Early computers were stand-alone work stations. The first networked computers used a "peer-to-peer" network. This was followed by LANs (Local Area Networks) that connected dedicated specialty servers with computers and printers for a common purpose. The Department of Defense developed the Internet as a means to provide communication at war time.
Individuals, schools and businesses can set up a LAN at their private location without paying a fee beyond the cost of the necessary hardware and software. Connection to the Internet requires an ISP (Internet Service Provider) and a monthly connection fee.
Many computers today, especially laptop computers, have wireless network connections. Such connections are convenient, but they are not as reliable and there is also a greater security risk.
Computers use hardware and software. Hardware peripheral devices are the visible computer components. There are external peripheral devices, such as monitors, keyboards, printers and scanners. There are also internal peripheral devices like disk drives, CD ROM drives, network interface cards and video cards.
Software falls into two categories of application software and operating system software. Application software includes the common applications of word processing and spreadsheets, but also tax return software and video games. Operating system software runs the computer and allows the user to personalize the computer to his or her needs and organize data.



1. What does ASCII stand for?

American Standard Code of Information Interchange


2. What ASCII range is used for the “standard set of characters”?

0..127
3. What ASCII range is used for the “extended set of characters”?

128..255
4. What is “bit” an abbreviation for?

BInary digiT


5. How many bits are in a byte?

8
6. How is Unicode different from ASCII?

It uses two bytes and adds many characters
7. What is a “nibble”?

4 bits
8. How many different combinations are possible with 2 bytes?

65,536
9. What number system is typically used to display memory addresses?

Base16
10. What is the main board in a computer, with all the primary computer components, called?

Motherboard
11. What kind of chip stores permanent information for the computer?

ROM
12. What does ROM stand for?

Read Only Memory
13. What kind of chip stores temporary information for the computer?

RAM
14. What does RAM stand for?

Random Access Memory
15. Which stores more information, gigabytes or terabytes?

Terabytes


16. Exactly how many bytes are in a kilobyte?

1024
17. What does CPU stand for?

Central Processing Unit
18. The CPU is essentially the _______ of the computer.

Brains
19. Is a protractor digital or analog?

Analog
20. What type of information allows you to make a precise copy of the original?

Digital
21. Define the word “program”.

A set of instructions to achieve a specified goal.
22. Explain why programming in machine language is undesirable.

Programming is 1s and 0s is very tedious and problematic.


23. Explain the difference between an interpreter and a compiler.

Compilers translates the entire file and then execute.

Interpreters translate each line and execute each line.
24. What is a “low-level” language?

Close to computer language


25. What is a high-level language?

Close to human language


26. Why do we not simply use English, or any other human language, to program a computer?

English is too ambiguous


11. What does OOP stand for?

Object Oriented Programming


13. What does “platform independent” mean?

A program can execute on any computer


14. When was Java released… and by whom?

Sun Micro Systems in 1995

19. What does LAN stand for?

Local Area Networks


20. What is a server?

A server is a specialty computer that is connected to the LAN for one or more purposes.

Servers can be used for printing, logon authentications, permanent data storage and communication.
27. What does hardware involve?

Hardware involves all the computer components that can be seen, felt, picked up and dropped, like a monitor, a mouse, a jump drive.


28. What does software involve?

Software involves the set of computer instructions that are coded on a disk, a CD, or a hard drive.


34. What does computer software do?

Computer software provides instructions to a computer.


35. Spreadsheets and word processors are examples of what kind of software?

Application Software


36. What does system software involve?

System software involves the instructions that the computer requires to operate properly.


37. List 3 major operating systems.

Windows XP/Vista/7, UNIX and MAC OS






Introduction to Java
Sun Microsystems provides free software to compile and execute Java programs. The Java Development Kit (JDK) can be found on Sun's website at http://java.sun.com. The current version (June, 2007) finished by Sun is Version 1.6.0 update 1.
The Java program language is designed to create full-fledged program applications for industry, as well as applets that will operate inside a web page. Normally, an application is a larger program than an applet. However, an applet is not necessarily a small program.
The secret of Java's success is the use of both a compiler and an interpreter. First, the Java compiler is used to create an intermediate stage in program translation, called bytecode. Second an interpreter is used to translate and execute the bytecode. Sun created multiple interpreters for different platforms. The interpreter is called a Java Virtual Machine (JVM). There are three distinct steps in creating a Java program.
The Java compiler and Java interpreter translate and then execute existing programs. You still need some tools to write the Java source code. It is possible to write code with any text editor and then use the command prompt to provide commands for compiling and executing. It is easier to use an Integrated Development Environment (IDE) like JCreator to assist in program writing. JCreator can be downloaded for free if you use the light edition. JCreator can execute both application programs and applet programs. You need to a special web page that imports the Java bytecode applet file.
The different components of a program were explained and you saw that a program uses keywords in program statements. Keywords have special meaning to a program. In particular, you looked at the keywords System.out.print and System.out.println. Both keywords display text output. Keyword println adds a carriage-return/line-feed (crlf) to the output statement.
The Java compiler checks to see that every program statement is written with correct syntax before a bytecode file is created. When mistakes are made, the compiler generates error messages about these mistakes.
Computers must be used in a responsible manner. First, care must be taken that a computer is not harmed physically or stolen. Computers are vulnerable and can be easily damaged. Computer data is stored in areas that can be easily corrupted and all important data needs to be backed up in one or more storage areas, like hard drives, CDs or memory sticks. Computers also need up-to-date protection programs against viruses, spyware and SPAM.
Using copyrighted software may be simple, but it is unethical. All software has license agreements that state if the software is free, licensed for one user, multiple users or an entire site, like a school or company. Many people hack into computers, supposedly for fun, unaware that they are inflicting damage with unknown computer hacking programs.


1. Explain why the United Nations “2-step translation” process requires fewer translators than a “1-step translation” process.

You only need 1 translator for every language and English.


2. When is a programming language considered to be platform independent?

When a program created on one computer can execute on all other computers.


3. What type of code is created by a Java compiler?

Bytecode
4. What is bytecode?

The intermediate code generated by the Java compiler
5. If you were to compare the executing of a Java file with the UN, how would “bytecode” fit in with the UN analogy?

Bytecode is English


6. Does the computer understand bytecode?

No
7. What does Java use an interpreter for?

To translate and execute bytecode
8. What does JVM stand for?

Java Virtual Machine


9. Which program is larger, a compiler or an interpreter?

Compilers are much larger.


10. Java uses a _______ to translate the program source code created by the programmer into _______.

compiler bytecode

11. Refer to the previous question. Java then continues and uses an _______ to translate the _______ into executable _______ line by line.

interpreter bytecode machine code


12. What is the name for the interpreter that takes the bytecode and then executes the program?

JVM
13. List 2 benefits with using Java on a web page?

It is secure and it is interactive
14. What does HTML stand for?

Hyper Text Markup Language


15. What is an applet?

A java program that executes inside a web page.


16. What is an application?

A program that executes stand-alone


17. Can a website contain multiple applets?

Yes
18. Can a website be written entirely in Java?

No
19. What 3 things do you need to write a Java program?

Text editor, compiler and interpreter


20. Refer to the previous question. Some software packages combine all 3 of these things into an IDE.

What does IDE stand for?

Integrated Development Environment

21. Can Notepad be used to write a Java program?

Yes
22. All Java programs end with what suffix?

.java
23. Can the Java compiler be accessed from the Command Prompt?

Yes
24. All bytecode files end with what suffix?

.class
25-27. What are the 3 steps of a Java program? (This counts as 3 questions.)



  • Write the Java source in some text editor.

  • Translate the source code file with a Java compiler into an intermediate bytecode file that will end with .class.

  • Execute the bytecode file with a Java Virtual Machine (JVM) program, which is an interpreter.

28. What does URL stand for?

Universal Resource Locator
29. What does JDK stand for?

Java Development Kit


30. What does JRE stand for?

Java runtime Environment


31. Why is the JRE necessary?

Allows executing Java programs


32. How much does it cost to download Java from Sun Microsystems?

It is free

33. When downloading the JDK from Sun Microsystems, what is the difference between downloading the Offline or the Online installation file?

The Online choice downloads a very small file with instructions to download additional information during software installation. The Offline choice downloads all the necessary files required for installation. This means that you can then install the software and it is not necessary to be connected to the Internet.


34. Java is an island in what country?

Indonesia


1. What is the difference between the PRO version and the LE version of JCreator?

The PRO version includes sophisticated debugging tools for the professional programmer.

The LE version is free.
2. What does GUI stand for?

Graphics User Interface


3. Look at figure 2.39. The first 5 lines of program Java0201.java all begin with //.

What does that mean?

These are all comments.
4. Are comments compiled into bytecode?

No
5. Every application program has a _______________ segment.

main
6. What does the command System.out.println do?

It displays the characters placed between the double quotes that follow.


7. What is a Java keyword?

A word that has a special meaning to Java


8. Two or more keywords combine to make what?

a program statement


9. What does it mean when we say that keywords in Java are “case-sensitive”?

That means that print and Print are two different words to Java.


10. List 7 keywords.

public, class, static, void, main, String and System.out.println.


11. What does CRLF stand for?

Carriage return, line feed


12. Explain the difference between print and println.

The print keyword generates output without a carriage return and the println keyword does include a carriage return.


13. What does println() do when there is nothing between the (parentheses)?

Skip a line


14. Both print and println follow what Java keyword(s)?

System.out


15. If you see public class Jessica in your program, what name must the file have?

Jessica.java


16. What punctuation symbols must be at the end of all Java program statements?

;
17. Physical damage to a computer happens, but it is not the biggest problem.

The number one source of grief for many people, especially students, is _______________________.

loss of data


18. What does RAM stand for?

Random Access Memory


19. What happens to the RAM if the computer loses power?

It is lost.

20. What does AVR stand for?

Automatic Voltage Regulation


21. What are the 2 parts of a computer virus?

The duplication part and the payload


22. What is spyware?

Special programs that snoop around your computer and try to record information

23. Why is it bad to leave your computer both logged in and unattended?

Anyone can go to your computer and copy, alter or erase anything.

24. What does USB stand for?

Universal Serial Bus




Java Simple Data Types
This chapter introduced the Java simple data types. A simple data type is simple because it stores a single value in memory. Simple data types are also called primitive data types. Program examples were shown that declared variables of a specified data type. Declaring the data type allows the compiler to allocate memory for the value to be stored.
There are four different integer data types: byte-1, short-2, int-4 and long-8 each indicated with their respective number of bytes in memory. Java provides five operators for integers: addition, subtraction, multiplication, integer-division and modulus-division.
There are two different real number data types: float-4 and double-8. Float is short for floating point number and double indicates that this data type is twice the precision of a float data type. Java provides four operators for real numbers: addition, subtraction, multiplication and real number division.
The specified data type is good for memory efficiency, but stingy use of memory can result in memory overflow. If a value is larger than the space reserved in memory, the result is incorrect, even if the mathematics is flawless.

In Java there are many shortcut notations for both unary operators and binary operators. Every arithmetic operator can be expressed in a shortcut notation. Keep in mind that multiple shortcut operations in the same statement can create very ambiguous program statements that are difficult to predict.


Java can declare character and string variables. The plus operator is used for arithmetic addition with numbers and concatenation with strings. Concatenation means that a string is appended at the end of another string. The String data type is included with the simple data types because we treat it like a simple data type right now. A string does hold multiple character values, but we process the entire set of characters as a single unit. You will learn in a later chapter the true nature of the String data type.
This chapter also introduced the boolean data type. This data type can store the value true or the value false. Boolean is included with this chapter to make the chapter complete with all the available simple data types. The actual usage of boolean will be shown later.
Java has a peculiar variable, called a final variable that cannot change. I prefer to call this a constant. Declaring a constant is identical to declaring a variable with the reserved final in front of the data type.
It is important to document your programs. Start by selecting identifiers that are self-documenting. Single-character identifiers should be avoided in most cases. Programs should also make generous use of meaningful comments that help explain the purpose of program segments and certain program statements.
Java programs use the same mathematical precedence that is used in mathematical computation. Logically, there is no apparent difference between mathematics and computers science. Practically, there are some differences. In mathematics there are assumed operations, especially multiplication that needs to be explicitly shown in a Java program. It is sufficient to state AB + CD in mathematics. In Java such an expression needs to be A*B + C*D.
It is possible to alter data types with type casting. Integers can become doubles and characters. Doubles can become integers and characters. Characters can become integers and doubles. Type casting is achieved by placing the new, desired data type inside parentheses in front of the variable to be altered.
Literal strings will not always display literally. Certain special characters following a single slash like \n, \t will result in a carriage return, a tab or some other special output display. The slash-character combination is called an escape sequence.



1. A program is made up of words, which usually are called what?

Keywords
2. What is the first Java syntax rule?

Use only keywords known by the Java compiler.
3. List the 3 categories of keywords.

Reserved words, pre-defined identifiers and user-defined identifiers


4. List 3 examples of Java Reserved Words.

public, static, void


5. Java has a large number of libraries that enhance the basic Java language. These libraries contain special program modules that perform a variety of tasks to simplify the life of a programmer. What are these modules called?

methods
6. List 2 examples of Predefined Identifiers.

print and println

7. When you are creating User-Defined Identifiers, you must make sure your identifier is not one of what two things?

A reserved word or a pre-defined identifier
8. What are the rules for naming an identifier?

Use alpha-numeric characters and start with an alpha character.


9. Print the Java statement that will declare x as an integer.

int x;
10. Refer to the previous question. Print the statement that will assign the value of 7 to x.

x = 7;
11. In program Java0301.java, why does the statement: System.out.println(a); display the value of 10 and not a?

The letter is not between double quotes.


12. Why does program Java0302.java not compile?

There are no values assigned to the variables.


13. Print the Java statement that will declare x as an integer and assign the value of 7 to x in one single statement.

int x = 7;


14. List Java’s 4 integer types.

byte, short, int and long


15. How many bytes are used by an int?

4

16. What is the largest value of a byte?

127
17. Would a short be appropriate to store Zip Codes?

No
18. Explain your answer to the previous question.

A short cannot hold any number above 32,767. Many zip codes are larger than this.
19. What are the 5 integer operations?

Addition, subtraction, multiplication, integer division and remainder division


20. What is the difference between the / and the % division operators?

/ is integer division and % is remainder division

1. In binary, what indicates if a number is positive or negative?

If the first bit is 0, the number is positive and if the first bit is 1, the number is negative


2. How is it possible for a computer to multiply 2 positive numbers, and get a negative product?

Memory flow, which alters the sign bit


3. Explain Memory Overflow.

A condition that occurs when the mathematical value is too large to be stored in the actual

computer memory space.
4. The Real Number data type that we will use is called double. Why is a double called a double?

It has double the bytes of a float


5. Which is more precise? A double, or a float?

Double


Assume x is an int for the next several questions.
6. What does x++; or ++x; mean?

In both case variable x is incremented by 1.


7. What does x--; or –x; mean?

In both cases variable x is decremented by 1.


8. Should Java shortcuts be combined with other Java statements? Example: System.out.println(x++);

No, it causes confusion


9. What does x += 5; mean?

Increase x by 5


10. What does x -= 5; mean?

Decrease x by 5


11. What does x *= 5; mean?

Multiply x by 5


12. What does x /= 5; mean?

Divide x by 5


13. What does x %= 5; mean?

Compute the remainder or dividing x by 5


14. What is the difference between the char and String data types?

The char type store one character and the String data type store one or more characters.
15. In program Java0312.java, what is accomplished by the statement: c1 = c2 = c3 = 'Q'; ?

Every variable is assigned the value of Q.


16. What is the fancy name for using the plus ( + ) sign to join strings together?

Concatenation


17. The plus ( + ) sign can be used to add integers and real numbers. It can also be used to join strings.

What is it called when one operator can perform different functions.

Overloading
18. What is “2” + “3” ?

23
19. Who invented a form of Algebra based on logical statements that are either true or false?

George Boole
20. Today, in computer science, a data type that has only two values of true and false is a called a _______ data type.

boolean
21. What is Java’s formal language for the term simple data types.

primitive
22. Say you want to use PI in your program with value of 3.14159. This value will never change in your program. Print the proper way to define and initialize this constant.

final double PI = 3.14159;


23. What happens when you attempt to alter the value of a final variable?

It causes a compile error.


24. What is a self documenting identifier?

An identifier, such as grossPay, that explains the purpose of the variable.


25. What is the difference between double-slash ( // ) comments and slash-star star-slash comments (/* */) ?

// is a single line comment

/* */ is a multiple line comment
26. Does Java follow the same Order of Operations that you learned in your Math

Yes
27. Translate 7abc into Java source code.

7 * a * b * c

x + 7


28. Translate ————— into Java source code.

2x - 3


(x + 7) / (2 * x - 3)

29. Translate “one half” into Java source code.

1.0 / 2.0 or 0.5
30. What is the output of: System.out.println( 10 / 3 ); ?

3
31. What is the output of: System.out.println( (double) 10 / 3 ); ?

3.333333
32. What is an escape sequence?

A special set of characters, starting with /, that means something to print, like \n


33. What does the escape sequence \n do?

carriage return, line feed


34. What escape sequence is used to generate a ?

\t
35. Why do we need escape sequences to generate backslash ( \ ) and quote ( " ) characters?

It prevents confusion to the compiler
36. What are the 4 data types that will be tested on the AP Exam?

int, double, boolean and String





Java Program Organization
Chapter IV introduced the fundamental program organization of Java. The organization of a program is similar to the organization of an English essay, story or book. Java keywords combine to form program statements. A group of program statements, which accomplish some specific purpose, are placed together in a container called a method. A set of methods with similar functions are placed inside a larger container, called a class.

A class also contains data, which is used by the methods. A class is a data type. One particular variable of a class is called an object.


The first methods introduced were methods of the Math class. Access to methods is done by using the class identifier, followed by a period and then the method identifier, like Math.sqrt(16). This approach is done with Math methods.
During this course you will be using a very large class, called Expo.


Things to Remember about the Expo class




  • The Expo class is not part of Java.




  • The class was created to simplify programming and allow students to focus on the logic of programming.




  • In order to use the Expo class, the file Expo.java must be in the same folder/directory as the .java file that calls the Expo class methods.




  • Students will NOT be required to memorize the methods of the Expo class. They will instead be provided with documentation to use during labs and tests.






1. Which programming language requires a very precise organization?

All of them
2. What spoken language is Java based on?

English
3. List 7 Java keyword.

public, main, System, int, double, print, void
4. Programming languages require special “containers” that their program statements are put in.

What are these containers called in Java?



Methods and classes
5. If a program has syntax errors, can it compile?

No
6. If a program does not compile, will a byte code file be created?

No
7. What must all program statements end with?

A semi-colon (;)
8. Are “method headings” and “class heading” program statements?

No
9. Which keywords in Java are case-sensitive?

All of them
10. What kind of operator is the equal sign (=) ?

An assignment operator
11. Why do computers exist?

To make life simpler
12. Modules that perform a related set of functions are grouped together in a special type of container.

What is this special container called?



A class
13. What do classes contain?

One or more methods
14. What do methods contain?

One or more program statements

15. What is the output of System.out.println(Math.sqrt(100)); ?



10
16. What is the output of System.out.println(Math.sqrt(64)); ?

8
17. What is the output of System.out.println(Math.sqrt(49)); ?

7
18. What is the output of System.out.println(Math.sqrt(25)); ?

5
19. What is the output of System.out.println(Math.sqrt(9)); ?

3
20. Refer to the previous question. What does Math signify?

The name of the class
21. Refer again to question 19. What does sqrt signify?

The name of the method
22. Refer yet again to question 19. What does 9 signify?

The argument/parameter/information being passed/sent to the method
23. What is a parameter used for?

It provides necessary information to the method.
24. Can Math.sqrt be used without a parameter?

No
25. List 4 different things that can be passed as a parameter.

    • a numerical constant,

    • a variable,

    • an expression ,

    • or even another method

26. The information, which is passed to a method is called an _____________ or a _____________.



argument or a parameter
27. Where are parameters placed?

Parameters are placed between parentheses immediately following the method identifier.
28. What happens if you alter a program - no matter how slightly - and then execute without recompiling?

You will be using the bytecode file that was created with an older version of the program.
29. The floor, ceil, and round methods of the Math class all “round” in some way.

What is the difference among them?



floor always rounds down

ceil always rounds up

round rounds normally
30. What is the output of System.out.println(Math.round(7.5)); ?

8
31. What is the output of System.out.println(Math.round(7.499)); ?

7
32. What is the output of System.out.println(Math.ceil(7.999)); ?

8
33. What is the output of System.out.println(Math.ceil(7.001)); ?

8
34. What is the output of System.out.println(Math.floor(7.999)); ?

7
35. What is the output of System.out.println(Math.floor(7.001)); ?

7
36. What is the output of System.out.println(Math.max(100,50)); ?

100
37. What is the output of System.out.println(Math.min(100,50)); ?

50
38. What is the output of System.out.println(Math.abs(-3)); ?

3
39. What is the output of System.out.println(Math.abs(3)); ?

3
40. What is the output of System.out.println(Math.pow(3,4)); ?

81
41. What is the output of System.out.println(Math.pow(4,3)); ?

64
42. What is the output of System.out.println(Math.pow(2,5)); ?

25
43. What is the output of System.out.println(Math.pow(5,2)); ?

32
44. Are PI and E “attributes” or “methods” of the Math class?

attributes


1. Is the Expo class part of the Java programming language?

No
2. Which type of method has more parameters: Math methods or graphics methods?

Graphics
3. Graphics images are not solid pictures, but images created with hundreds or thousands of individual colored dots. What are these individual graphics dots called?

Pixels
4. What is the minimum requirement of any call to a graphics method?

information about the location or coordinates for the picture
5. What is the name of the coordinate system that has 4 quadrants and the point (0,0) in the center?

Cartesian
6. List 2 differences between a Cartesian graph and a computer graphics screen.

The (0,0) coordinate is located in the left-top corner of the applet window, instead of the middle.

In a Cartesian system Y-values increase from the bottom to the top.

In a computer graphics system Y-values increase from the top down to the bottom.
7. What method is always found in an application?

main
8. Refer to your answer to the previous question.

Applets do not have this method. What do they have instead?

A paint method
9. What 2 libraries must be imported in order for graphics applets to work?

import java.awt.*;

import java.applet.*;
10. What does awt stand for?

abstract windows tools
11. When working with applications, you compile and execute the same file.

When working with an applet, what file is compiled? And what file is executed?



Compile the .java file and execute the .html file.
12. In the Expo class, what is the first parameter of any method that does anything graphical?

The Graphics object g.
13. What parameters are required by both drawPixel and drawPoint?

They need the Graphics object g, as well as the X and Y value of the pixel/point.
14. What is the difference between drawPixel and drawPoint?

drawPixel only plots one pixel. drawPoint actually draws a 3 by 3 “square” of 9 pixels.
15. Which of these files stored the height and width of the applet window?

The .html file
16. Applets can be executed in JCreator. Where else can they be executed?

Any web browser like Internet Explorer.
17. Like drawLine, drawRectangle requires that you also specify 2 coordinate points.

What do they represent?



the upper-left-hand coordinate (X1,Y1) and the lower-right-hand coordinate (X2,Y2)
18. What is the mathematical definition of a circle?

A set of points that are equidistant from a given point


19. What is the radius of a circle?

The distance from the center of the circle to any point on the edge of the circle
20. What parameters are necessary for drawCircle?

The Graphics object g, the X and Y coordinate of the center, as well as the radius.
21. How is an oval different from a circle?

A circle has one radius. An oval has 2 radii.
22. In a drawOval commands, what will the output look like if the same value is passed for the horizontal radius and the vertical radius?

A circle
23. In a drawOval commands, what will the output look like if the horizontal radius is greater than the vertical radius?

A short-fat oval
24. In a drawOval commands, what will the output look like if the horizontal radius is less than the vertical radius?

A tall-thin oval
25. What is an arc a piece of?

An oval
26. The first 5 parameters of drawArc are identical to drawOval.

drawArc adds 2 more parameters at the end. What do these 2 parameters specify?

the starting degree value and the stopping degree value




In questions 1 through 10, you are using the Expo.drawArc method to draw each of the arcs that are displayed. You need to provide the last 2 parameters.


#

Arc to be drawn

Starting Degree Value

Stopping Degree Value

1.



90

270

2.



270

90

3.



0

180

4.



180

0 or 360

5.



0

90

6.



180

270

7.



270

0 or 360

8.



180

90

9.



90

0 or 360

10.



270

180

11. Does the order of the parameters matter ?



Yes
12. The parameters of drawSpiral are identical to which method?

drawCircle
13. What is meant by the radius of a star?

The distance from the center of a star to any point
14. The parameters of drawStar are very similar to drawCircle.

The difference is drawStar has an extra parameter at the end. What does it specify?



The number of points on the star.
15. If you want to draw solid rectangles, circles, ovals, and stars, what methods would you use?

fillRectangle, fillCircle, fillOval and fillStar
16. What happens when a small shape is drawn on top of a large shape that is the same color?

The small object will not show up.


17. What is the default drawing/filling color?

Black
18. How many colors are built into the Expo class?

25
19. If you want to draw PAC-MAN, what method would you use?

fillArc




20. All draw methods of the Expo class have a corresponding drawThick method which have the exact same parameters, except for one extra parameter at the end. What does that parameter specify?

The thickness of the shape
21. What file contains the documentation of the Expo class.

Expo.html
22. Refer to your answer to the previous question. When you look at this file, you will see brief “one-sentence” descriptions of each of the methods of the Expo class. What do you need to do if you want more detailed information on a particular method?

Click on the name of the method.
23. In a method’s documentation, what does the precondition specify?

The precondition specifies what must be true for the method to work properly.
24. In a method’s documentation, what does the postcondition specify?

The post condition specifies what is true after the method is finished.
25. If a method has BOTH a precondition and a postcondition, what must be true for the postcondition to happen?

The precondition must be true.
26. What does NaN stand for?

Not a Number




Alice: Chapters 1-2
True or False


  1. 30) According to the Alice text, learning to program makes you a computer nerd



31) According to the Alice text, Computer Scientists refer to “If” statements as Conditional Execution.



32) In Alice, an object has 5 degrees of orientation (ie. Up, down, back, left, right)



  1. 33) In Alice, an object has 6 degrees of freedom:



Multiple Choice


  1. 34) An object is: __________________________________________________.





  2. 35) Alice is written in ____________________.



  3. 36) In Alice, the Object Tree contains ____________________________________________________________.



37) In Alice, an instruction is ______________________________________________________.



  1. 38) Creating a computer program is a _______________-step process which includes _________________, _________________, _________________, _________________ .




  1. 39) “Algorithmic” means “___________________”



  1. 40) It is “possible”/“impossible” to make a syntax error in Alice



  2. 41) In the Circling Fish exercise from Ch. 2, the most effective way to circle the fish around the Island is to




  1. __________________________________________________________________________________________.



  2. 42) In computing terminology, a textual storyboard is called ____________________.



  3. 43) A program is a __________________________________________________________________________.






  1. 44) A method is a ___________________________________________________________________________.



  1. 45) SceneEditor’s Layout Manager is used to _____________________________________________________.



    1. 46) A sequential action block requires/does not require a Do Together method .



    2. 47) Give a couple examples of a Control Statement in Alice: _________________, ___________________



    3. 48) Give an example of an Argument required to execute the action (Method) “turn to face”: ________________.



    4. 49) A __________ colored line in the Alice Editor Area indicates where an instruction (e.g. method, control structure) will be dropped.



    1. 50) Nesting is the practice of __________________________________________________________________.





    2. 51) Give an example of using a Trial and Error strategy in developing Alice code:




    1. __________________________________________________________________________________________.



    2. 52) In computer science terminology, a Bug is a ___________________________________________________.




    1. 53) The technical term for “while the animation is running” is at ______________.



    2. 54) Comments are instructions that cause/do not cause some action to take place.



    3. 55) Comments in Alice are indicated by what? ____________________________________________________



    4. 56) Duration, Style and As Seen By are examples of ____________________.



    5. 57) A Control Structure, such as a Do in order or a Do together statement is a ____________________________




    1. __________________________________________________________________________________________.




    1. 58) An if/else statement involves making a ________________.




    1. 59) “snowman turn to face” is an example of an ___________________.



    2. 60) A ________________ is a function that checks a condition or computes a values.



    3. 61) ___________________ __________________ (such as if/else statements and repetition) makes use of questions and expressions to check a current condition in a world.



    4. 62) Give a couple examples of properties of the object Boy (placed in a world). ___________________________



    5. 63) “left arm” is an example of a ______________ of a “Boy” object.





Download 211.14 Kb.

Share with your friends:




The database is protected by copyright ©ininet.org 2024
send message

    Main page