Java Chapter 1

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

What would the following statement, when used in a Java Program, display on the screen? System.out.println("Java is great!");

Java is great!

What are the two kinds of memory in a computer?

Main Memory and Auxiliary Memory

Do all object of the same class have the same methods?

Yes

Suppose you compile the class YourClass. What will the name of the file containing the resulting bytecode?

YourClass.class

What do you call a program that translates Java bytecode into machine language instructions?

a machine that translates java bytecode instructions to machine language instructions.

What is psuedocode?

a mixture of English and java that you can use to write the steps of an algorithm

What is a syntax error?

grammatical mistake in a program.

What is a source program?

high level language program that is input to a compiler

Is Java a high-level language or a low-level language?

high-level

What is algorithm?

set of directions for solving a problem.

What kinds of errors are likely to produce error messages that will alert you to the fact that your program contains an error?

syntax errors and run-time errors

What is a compiler?

translates a high level language to a low level language

What is the relationship between classes and objects?

A class is a blue print for creating objects. All objects in the same class have the same kind of data and the same methods.

What is the difference between a program written in a high level language, a program in a machine language, and a program expressed in Java bytecode?

A high level language program is written in a form that is easy for a human being to write and read. A machine-language program is written in a form the computer can execute directly. A high-level language program must be translated into a machine-language program before the computer can execute it. Java bytecode is a low level language that is similar to the machine language of most common computers. It is relatively easy to translate a program expressed in Java bytecode into the machine language of almost any computer.

What is a method?

A method defines an action that an object is capable of performing.

What data would you give to a program that computes the average of all the quizzes you have taken in a course?

All the grades on the quizzes you have taken in the course.

What is encapsulation?

Encapsulation is the process of hiding all the details of an object that are unnecessary to using the object. Put another way, encapsulation is the process of describing a class or object by giving only enough information to allow a programmer to use the class or object.

What is a software?

Software is just another name for programs.

Write a statement or statements that can be used in a Java program to display the following on the screen. Java for one. Java for all.

System.out.println("Java for one")

Suppose you define a class name YourClass in a file. What name should the file have?

The file containing the the class YourClass should be named YourClass.java

What is the meaning of the following line in the program in Listing 1.1? n1 = keyboard.nextInt() ;

The statement reads a whole number typed in at the keyboard and stores it in the variable n1.

What data would you give to a program that computes the sum of two numbers?

The two numbers to be added.

What attributes would you want for an object that represents a song?

Title, composer, date, performer, album title

Write an algorithm that counts the number of values that are odd in a list of integers.

add 1 to the number, replace the old number on the blackboard with the result of the addition

What is information hiding?

another word for encapsulation

What is a logic error?

conceptual error in a program or its algorithm.

What is inheritance?

defining specialized classes that add to or revise the details of the general class.

Suppose you write a program that is supposed to compute the day of the week (Sunday, Monday, and so forth) on which a given date ( like December 1, 2011) will fail. Now suppose that you forget to account for leap years. Your program will then contain an error. What kind of program is it?

logical error

Is Java bytecode a high-level language or a low-level language?

low-level

Suppose that mary is an object that has the method increaseAge. This method takes on argument, an integer. Write an invocation of the method increaseAge by the object mary, using argument 5.

mary.increaseAge(5)

What is polymorphism?

one method name, used as an instruction, can cause different actions, depending on the kid of object performing the action.

Write a complete Java program that uses System.out.println to display the following on the screen when the program is run: Hello World!

public class Question15 { public static void main(String[] args) { System.out.println("Hello World")


Set pelajaran terkait

Equivalent Fractions, Decimals and Percentages

View Set

Nutrition & Drugs - Ch. 6 Fats & Lipids

View Set

Chapter 16; Cardiovascular Emergencies

View Set

Health Promotion and Maintenance 3

View Set

2) Skeletal System Anatomy, Intro - Appendicular vs. Axial, Intro - Bone Classifications by Shape,

View Set