IT 168 test 1

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

Write a prompt and the statement to read the square footage in a tract of land from the keyboard.

. System.out.print("Please enter the number of square feet in a tract of land: "); squareFeet = keyboard.nextInt( );

Given the following declarations, determine the value of each expression below. If the result is a floating-point value, include a decimal point in your answer. int i=4; int j=17; double z=2.6; z * j

44.2

Given the following declarations, determine the value of each expression below. If the result is a floating-point value, include a decimal point in your answer. int i=4; int j=17; double z=2.6; 2 * 3 - 1 % 3

5

What value is stored into the int variable, result, in each of the following? result = (int) (4.5 + 2.6 * 0.5);

5

Given the following declarations, determine the value of each expression below. If the result is a floating-point value, include a decimal point in your answer. int i=4; int j=17; double z=2.6; j / 2

8

The two commonly used success specifiers are public and private. What is the purpose of an access specifier? What is the difference between public and private?

Access specifiers determine whether other classes can use a particular field or invoke a particular method. private - the class member cannot be accessed by code outside the class. The member can be accessed only by methods that are members of the same class. public - the class member can be accessed by code inside and outside of the class.

One acre of land is equivalent to 43,560 square feet. A program needs to be written called AcreCalculator that calculates the number of acres in a tract of land. Hint: divide the size of the tract of land by the size of an acre to get the number of acres. What is the name of the class?

AcreCalculator

One acre of land is equivalent to 43,560 square feet. A program needs to be written called AcreCalculator that calculates the number of acres in a tract of land. Hint: Divide the size of the tract of land by the size of an acre to get the number of acres. What is the file name with extension of the compiled code that has been translated to byte code?

AcreCalculator.class

One acre of land is equivalent to 43,560 square feet. A program needs to be written called AcreCalculator that calculates the number of acres in a tract of land. Hint: Divide the size of the tract of land by the size of an acre to get the number of acres. What is the name of the source code file with extension?

AcreCalculator.java

Define the different testing levels: d) Regression testing

Focuses on finding defects after a major code change has occured.

What does it mean to say a program is portable?

It may be written on one type of computer and then run on a wide variety of computers with little or no modification necessary.

In what language does a computer's CPU process instructions?

Machine language

Do the CPUs of all computers use the same language?

No

Write a statement to create an object for a scanner to read input from the keyboard.

Scanner keyboard = new Scanner(System.in);

What is the definition of a computer program?

Set of instructions that enable the computer to solve a problem or perform a task

Write the output statement to print the square feet and acres with appropriate labels. Use the DecimalFormat objects created in questions 2 -the first one for square feet and the second one for acres.

System.out.println(pattern0comma000.format(squareFeet) + " square feet = " + pattern0dot0.format(acres) + " acres");

One acre of land is equivalent to 43,560 square feet. A program needs to be written called AcreCalculator that calculates the number of acres in a tract of land. Hint: Divide the size of the tract of land by the size of an acre to get the number of acres. Write the output statement to print the square feet and acres with appropriate labels.

System.out.println(squareFeet+"squareFeet="+acres+"acres");

What is the hardware part of a computer system and list the major hardware components of a typical computer system?

The physical components a) CPU b) Main memory (RAM) c) Secondary storage devices (hard drive, CD, DVD, . . .) d) Input devices (keyboard, mouse, scanner, . . .) e) Output devices (monitors, printers, . . .)

What is the purpose of software testing?

Validates and verifies that a software program/application/product: a) meets the business and technical requirements that guided its design and development b) works as expected

Define the different testing levels: a) unit testing

Verify the functionailty of a specific section of code.

Define the different testing levels: b) Integration testing

Verify the interfaces between components.

What is the difference between white box and black box testing?

White Box Testing a)Tester has access to the internal data structures and algorithms including the code. Black Box Testing a) Treats the software as a "black box" without any know of internal implementation.

What are the common elements of a programming language?

a) Key words (reserved words) b) Operators c) Punctuation d) Programmer-defined names e) Syntax - rules

What are the two general categories of software?

a) Operating system b) Application software

What is an algorithm?

a) Set of well-defined steps for performing a task or solving a problem. b) Sequentially ordered

What are the three types of errors found in a Java program and describe each one?

a) Syntax errors I) using the language rules incorrectly b) Runtime errors I) occur when the program is executing and cause it to end abnormally or display strange results c) Logic errors 1) errors in thinking I) erroneous behavior in a program or incorrect output

Write the statements to format a double variable print statement for a) An amount of money with a $ sign and two decimal places b) one decimal place

a) System.out.printf("$%.2f", number); b) System.out.printf("%.1f", number);

What terms are used in OOP for: a) data? b) behavior?

a) attribute (also field, instance variable) b) method

One acre of land is equivalent to 43,560 square feet. A program needs to be written called AcreCalculator that calculates the number of acres in a tract of land. Hint: Divide the size of the tract of land by the size of an acre to get the number of acres. Declare and initialize two variables: a)to hold the square feet entered as a whole number b) to hold the number of acres which must store decimal places

a) int squareFeet=0; b) double acres=0;

What are the naming rules for identifiers?

a) length is limited b) must begin with a letter c) case sensitive d) cannot be a keyword, boolean literal(true or false), or a reserved word. e) can contain: 1) letters (A-Z, a-z) 2) digits 3) any Unicode character 4) underscore (_) symbol 5) dollar sign ($) f) must be unique within its scope g) cannot include spaces

Combining data and behavior in the same entity is called __?__

encapsulation (combining of data and code into a single object)

Define the different testing levels: c) System testing

entire system is tested determind by the requirements.

One acre of land is equivalent to 43,560 square feet. A program needs to be written called AcreCalculator that calculates the number of acres in a tract of land. Hint: Divide the size of the tract of land by the size of an acre to get the number of acres. Write a declaration for the constant to hold the number of feet per acre.

final int FEET_PER_ACRE=43560;

Dynamic binding or late binding, when the JVM determines at runtime which method to call based on an object's type rather than a variable's type, the ability to treat many types as a single type, is what OO key concept?

polymorphism

What type of programming separates the data from the behavior (programming statements that perform a specific task)?

procedural programming

One acre of land is equivalent to 43,560 square feet. A program needs to be written called AcreCalculator that calculates the number of acres in a tract of land. Hint: Divide the size of the tract of land by the size of an acre to get the number of acres. Write the class header statement.

public class AcreCalculator{

One acre of land is equivalent to 43,560 square feet. A program needs to be written called AcreCalculator that calculates the number of acres in a tract of land. Hint: Divide the size of the tract of land by the size of an acre to get the number of acres. Write the main method header.

public static void main (String[ ] args){

Write an assignment that typecasts a double variable, balance, to an integer and stores it in an integer variable simpleBalance.

simpleBalance = (int) balance;

Write an assignment statement that typecasts a double variable balance to an integer and stores it in an integer variable simpleBalance.

simpleBalance=int balance;

In Eclipse you create Java __?__ and the file created has what extension?

source code .java

The Java programming statements written by the programmer in a text editor are called __?__ and the file when saved has what extension?

source code .java

By convention, where should the following identifiers use uppercase or lowercase letters? (For the first three which should the first letter be?) method

start with a lowecase letter (method)

By convention, where should the following identifiers use uppercase or lowercase letters? (For the first three which should the first letter be?) variable

start with a lowercase letter (variable)

By convention, where should the following identifiers use uppercase or lowercase letters? (For the first three which should the first letter be?) class

start with an uppercase letter (Class)

Why create a package instead of just using the default?

to organize your files.

What value is stored into the int variable, result, in each of the following? result = 7 / 3 + 2;

4

What value is stored into the int variable, result, in each of the following? result = 17 + (21 % 6) * 2;

23

(int) (z + 0.5)

3

What value is stored into the int variable, result, in each of the following? result = 15 % 4;

3

What value is stored into the int variable, result, in each of the following? result = 2 + 7 * 5;

37

Give an example of when a value needs to be typecast and why.

A type cast often needs to be used when the result of integer division needs to be a double value.

Given the following declarations, determine the value of each expression below. If the result is a floating-point value, include a decimal point in your answer. int i=4; int j=17; double z=2.6; i + j % 1

4

One acre of land is equivalent to 43,560 square feet. A program needs to be written called AcreCalculator that calculates the number of acres in a tract of land. Hint: Divide the size of the tract of land by the size of an acre to get the number of acres. Write the class comment block.

/** * Calculate the number of acres in a tract * when given the size in square feet. * * @author Cathy Holbrook * */

One acre of land is equivalent to 43,560 square feet. A program needs to be written called AcreCalculator that calculates the number of acres in a tract of land. Hint: Divide the size of the tract of land by the size of an acre to get the number of acres. Write the beginning comment block (you are the author of the program).

/********************************** * Programmer: Pauline Fittanto * * Date: * * File name: AcreCalculator.java * * Class: IT 168 * Section: * Instructor: Tonya Pierce *************************************/

Given the following declarations, determine the value of each expression below. If the result is a floating-point value, include a decimal point in your answer. int i=4; int j=17; double z=2.6; (1 / 2) * 1

0

Given the following declarations, determine the value of each expression below. If the result is a floating-point value, include a decimal point in your answer. int i=4; int j=17; double z=2.6; I / (double) j

0.2352

What would you see if you looked at a program in this language (from Q. 6)?

0s and 1s

Given the following declarations, determine the value of each expression below. If the result is a floating-point value, include a decimal point in your answer. int i=4; int j=17; double z=2.6; i % j / i

1

What is the difference between a class and an object?

1) A class is a a) collection of programming statements that specify the attributes and the methods that a particular type of object may have. "blueprint" that objects may be created from. description of an object. 2) An object is an instance of a class created using a new operator. allocated in memory 3) From wiki A class is basically a definition, and contains the object's code. An object is an instance of a class. For instance, there is one java.lang.String class, but you can instantiate any number of distinct java.lang.String objects (instances). While a class defines the instance variables that an object has, the instantiated object itself actually contains those variables. So to put it simply: An object is an instance of a class.

Given the following declarations, determine the value of each expression below. If the result is a floating-point value, include a decimal point in your answer. int i=4; int j=17; double z=2.6; 1.0 / i + 2

2.25

Given the following declarations, determine the value of each expression below. If the result is a floating-point value, include a decimal point in your answer. int i=4; int j=17; double z=2.6; 2 * i + j - i

21

What value is stored into the int variable, result, in each of the following? result = 45 / 8 * 4 + 2;

22

What is pseudocode?

A cross between human language and a programming language and is especially helpful when designing an algorithm.

What is a Java Virtual Machine (JVM) and what does it do?

A program that reads Java byte code instructions and executes them as they are read.

What special consideration do you need to consider when reading a string after reading an int value?

An extra statement needs to be used to read the '\n' left after the int value. keyboard.nextLine( );

How many objects of a class can be created in memory?

As many as needed.

Write the statement to calculate the number of acres from the input number of square feet. Declarations for variables are: int squareFeet=0; final int FEET_PER_ACRE=43560;

acres = (double) squareFeet / FEET_PER_ACRE;

One acre of land is equivalent to 43,560 square feet. A program needs to be written called AcreCalculator that calculates the number of acres in a tract of land. Hint: Divide the size of the tract of land by the size of an acre to get the number of acres. Write a statement to calculate the number of acres from the input number of square feet.

acres=(double)squareFeet/FEET_PER_ACRE;

By convention, where should the following identifiers use uppercase or lowercase letters? (For the first three which should the first letter be?) package

all lowercase (package)

By convention, where should the following identifiers use uppercase or lowercase letters? (For the first three which should the first letter be?) constant

all uppercase (CONSTANT)

A Java compiler translates Java source code into __?__ and the file created has what extension?

byte code .class

OOP is an acronym for __?__

object-oriented programming

What type of programming combines the data and behavior?

object-oriented programming

When using the metaphor of a cookie cutter and cookie, which is the class and which is the object?

cookie cutter -> class, cookie -> object

One acre of land is equivalent to 43,560 square feet. A program needs to be written called AcreCalculator that calculates the number of acres in a tract of land. Hint: Divide the size of the tract of land by the size of an acre to get the number of acres. If the package name is edu.ilstu, write the package statement.

package edu.ilstu;

A class based on another class to promote code reuse is known as __?__.

inheritance

An object created from a class is also called an __?__ of the class.

instance

The fundamental means of communication between objects is called the __?__. a. This term refers to the abstraction that an entity provides of itself to the outside. b. The connection between two points, where the communication occurs.

interface

What Java keyword is used to create an object of a class?

new

What methods are used from the scanner class to read: b) a double

nextDouble()

What methods are used from the scanner class to read: a) an int

nextInt()

What methods are used from the Scanner class to read: c) a String

nextLine( ) or next( )

What methods are used from the Scanner class to read: d) a character

nextLine( ) or next( ) with charAt(0nextLine( ) or next( ) with charAt(0)

A good program always begins with __?__

planning


Set pelajaran terkait

MAN 1 Chapter 7 (Innovation and Change)

View Set

Chapter 9: Revolutions of Industrialization 1750-1900

View Set

Ch 18: Caring for Pts with Cancer, Chapter 18: Caring for Clients with Cancer, Chapter 18 - Caring for Clients with Cancer, Chapter 18: Caring for Clients with Cancer Prep -U, Chapter 18: Caring for Clients with Cancer Prep -U, Chapter 18, Chapter #1…

View Set

ch 17 (002) transcription, RNA processing, and translation

View Set

Beatles Exam #1 (1962, 1963, 1964)

View Set