Java - Chapter 1

¡Supera tus tareas y exámenes ahora con Quizwiz!

A method is called by specifying the ______ and it's _______.

1. Method , 2. Argument

1.1 What is required to play a music CD on a computer

A program that reads the data on the CD and sends output to the speakers and the screen.

1.2 Why is a CD player less flexible than a computer ?

Ac CD player can do one thing , play music CDs. It cannot execute programs

Pseudocode:

An informal description of a sequence of steps for solving a problem.

The technical term for Values is ______

Arguments

Java compiler translates source code into _____ files

Class

______ are the fundamental building blocks of java programming

Class

System.ou.println("Hello World"); is an example of which kind of error ? Compile or Run-time?

Compile Error ( Syntax error)

From Algorithm to Programs: The Final or 5th step: ____________.

Compile and test your program.

From Algorithm to Programs: The 2nd step: ____________.

Develop and describe an algorithm

An____ is a program for entering and modifying text such as a java program.

Editor

System.out.printlin(1/0) is an example of which of error?

Exception - a type of a run-time error.

What does the following statements print? System.out.println("Hello"); System.out.println(""); System.out.println("World");

Hello // a blank line World

What is the output of System.out.println("Hello"); System.out.println("World");

Hello World

1.4 Where is a program stored when it it not currently running.

In a secondary storage , typically a hard disk.

Each method contains a sequence of ______

Instructions

How is a smartphone similar to desktop computer

It has CPU and memory. A touch pad instead of an actual keyboard , place of memory storage such as a SSD , and speakers and microphones. The network connection uses the wireless radio to connect to a cell tower.

1.16- Suppose you leave the" Characters around Hello , World from HelloPrinter.Java program. Is this a compile-time error or a run-time error?

It is a Compile (Syntax Error), because with out the quotations , the compiler would have to look for a meaning to Hello and world.

A run-time error is also know as _______ error.

Logic

The name of the public class must _____ the name of the file containing the class

MATCH

a______ contains a collection of programming instructions that describe how to carry about a particular task

Method

Suppose each photo in Self Check 23 had a price tag. Give an algorithm for finding the most expensive photo.

Pick the first photo and call it "the most expensive so far". For each photo in the sequence If it is more expensive than "the most expensive so far" Discard "the most expensive so far". Call this photo "the most expensive so far". The photo called "the most expensive so far" is the most expensive photo in the sequence

What is the difference between Sytem.out.println and System.out.print method ?

Println: prints a string or a number and THEN stars a newline. print: used to print an item WITHOUT starting a newline.

System.out.println("Hello World"); is an example of _____ which kind of error ? Compile or Run-time error?

Run-Time error (Logic) error

Exception is a type of _____ error

Run-time

The body of the main method contains ________

Statements

A compile-time error is also know as ________ error.

Syntax

How would you modify the Helloprinter program to print the word "Hello" Vertically ?

System.out.println("H"); System.out.println("e"); System.out.println("l"); System.out.println("l"); System.out.println("o");

An example of a method with a single statement

System.out.println("Hello World);

1.11 , How do you modify the HelloPrinter program to greet you instead?

System.out.println("Hello, TakeN!");

From Algorithm to Programs: The 3rd step: ____________.

Test the algorithm with simple inputs

What does the following set of statements print? System.out.print("My Lucky number is: "); System.out.println("3+4+5);

The output is: My Lucky number is: 12

From Algorithm to Programs: The 4th step: ____________.

Translate the algorithm into Java

1.20- Why can't you test a program for run-time errors when it has compiler error?

When a program has compiler errors, no class file is produced, and there is nothing to run.

1.10 What do you do to protect yours eflt from data loss when your work on programming projects ?

You back up your files and folders

String

a sequence of characters enclosed in double quotation marks.

1.26 Suppose you have a random sequence of colored marbles. Consider this pseudocode: check slide 60. in chapter 1

check slide 60. in chapter 1

_____ files contain instructions for the Jave _________ __________

class , virtual, machine

Compile-time error (syntax error)

is a violation of the programming language rules detected by the compiler.

declaring a main method

public static void main (String[] args){ ....}

Each class contains declaration of _________

Methods

1.13, Would the program continue to work if you replaced line 7 with this statement ? System.out.println(Hello);

No , because the compiler would look for an item whose name is Hello. So in order to print the text "Hello" you need to have quotation marks like this: System.out.println("Hello");

1.8 , How long does it take to learn the entire java library

No one person can learn the Entire Library , because it's too large

1.3 What does a computer user need to know about programming in order to play a video game ?

Nothing.

1.7 What are the 2 most important benefits of the java Language

1. Safety 2.. Portability

A method call requires 2 things.

1. The method you want to use , EX: System.out.println 2. Any value the method needs to carry out it's task which is enclosed by parentheses , EX: ("Hello World")

An Algorithm is a sequence of steps that is : 1._______2.________3._______

1. unambiguous - doesn't have more than 1 meaning 2. executable - to run by a computer 3. Terminating- To come to an end.

Consider the following pseudocode for finding the most attractive photo from a sequence of photos: ____________ Pick the first photo and call it "the best so far". For each photo in the sequence If it is more attractive than the "best so far" Discard "the best so far". Call this photo "the best so far". The photo called "the best so far" is the most attractive photo in the sequence. ______________ Is this an algorithm that will find the most attractive photo?

No. The step If it is more attractive than the "best so far" is not executable because there is no objective way of deciding which of two photos is more attractive.

1.17- Suppose you change println to printline in the HelloPrinter.java program. Is this a compile-time error or a run-time error?

This is a compile-time error , because the compiler will complain that System.out DOES NOT have a method called printline.

Java is _____ sensitive

Case

1.5 Which part of the computer carries out arithmetic operations , such a s addition and multiplication.

CPU.

A run-time error

Causes a program to perform an action that the programmer did not intend.

In java , every source file can contain at most _____ public class

One

1.25 Suppose you have a random sequence of black and white marbles and want to rearrange it so that the black and white marbles are grouped together. Consider this algorithm ( Check slide)

check slide for chapter 1 slide number 59.

What is the output of System.out.println(3+4);

7

1.18- Suppose you change main to hello in the HelloPrinter.java program. Is this a compile- time error or a run-time error?

This is a run-time error , because it's okay to have a method called"Hello", so the compile won't complain . BUT , when you run the program , the virtual machine will look for a main method and won't find one.

When you used your computer , you may have experienced a program that "crashed" (quit spontaneously) or "hung" (failed to respond to your input ). Is this behavior a compile-time error or a run-time error?

This is a run-time error , because the program has already been complied in order for you to run it.

From Algorithm to Programs: The 1st step: ____________.

Understand the problem.

Every Java Application contains a class with a _____ method.

main


Conjuntos de estudio relacionados

STR581: Ch 2: Charting a company's direction

View Set

Environmental Science- Chapter 1 Test

View Set

OB-Ch. 23 Quiz NB W/ Special Needs Quiz ?s

View Set

Math Review 1: Literal equations

View Set