MIS 3330 - Chapter 1-5

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

When you code an if statement within another if statement, the statements are nested

true

The equal to relational operator is ___.

"=="

The operator that combines two conditions into a single Boolean value that is true only when both of the conditions are true is ___.

&&

The method public static boolean testValue(int response) returns ____________.

A Boolean value

A LocalDate object ___.

Can be displayed as a String

The this reference ___.

Can be used implicitly

A constructor ___ parameters.

Can receive

There are three types of if statements: single-alternative, dual-alternative and reverse.

FALSE

The method with the declaration public static int aMethod(double d) is a method type of ___________

Int

A method variable ___ a class variable with the same name.

Override

The values of an object's attributes are known as its:

State

If a method is written to receive a double parameter, and you pass an integer to the method, then the method will ____.

Work correctly; the integer will be prompted to a double.

Which of the following is a correct call to a method declared as public static void aMethod(char code)?

aMethod('Q');

Which assignment is correct in JAVA?

char aChar = '*';

A public static method named computeSum() is located in ClassA. To call the method from within ClassB, use the statement ____________.

classA.computeSum();

Which of the following statements correctly outputs the names of voters who live in district 6 and all voters who live in district 7?

if(district == 6 || district ==7) System.out.println("Name is" + name);

All Java applications must have a method name ___.

main() - every java application must have the main() method. program executions start from main.

Which of the following statements determines the square root of a number and assigns it to the variable s?

s = Math.sqrt(number);

Assuming you have declared shoeSize to be a variable of type int, which of the following is a valid assignment statement in Java?

shoeSize = 9; (since variable type is a int; only whole numbers can be stored in it)

A method is declared public static void showResults(double d, int i) which of the following is a correct method call?

showResults(12.2, 67);

How to write a Hello World Program

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

Java classes are stored in a folder or ___.

Package

All method declarations contain ____________.

Parentheses

Arguments to methods always appear within ____.

Parenthesis - followed by method name and arguments are in between.

Assuming a variable w has been assigned to the value 15, what does the following statement do? w == 15 ? x = 2: x = 0;

Assign 2 to x

A constructor ___ overloaded.

Can be

A ___ translate high-level language statements into machine code.

Compiler - a computer system understands machine level language, and user writes his program in high-level language. There's a mediator called compiler used to translate high-level language statements into machine level code.

Which of the following is typically used in a flowchart to indicate a decision?

Diamond

which of the following cannot be an argument tested in a switch statement?

Doube

When you perform arithmetic with values of diverse types, java _____.

Implicitly converts the values to a unifying type.

The command to execute a complied Java application is ___.

Java

You send messages or information to an object through its ___.

Methods

Non-ambiguous, overloaded methods must have the same ____.

Name

Methods that you reference with individual objects are ___.

Non-static

Most class data fields are ____________.

Private

If you declare a variable as an instance variable within a class, and you declare and use the same variable name within a method of the class, then within the method, ____.

The variable used inside the method takes precedence

If a class is named Student, the class constructor name is Student().

True

Named computer memory locations are called ____:

Variables - are named memory locations that hold values that might vary.

You can declare variables with the same name multiple times ___.

Within a method;

Which assignment is correct in Java?

double money = 12.0;

Which of the following has the lowest precedence?

||

The operator that combines two conditions into a single Boolean value that is true when at least one of the conditions is true is ___.

|| -- Logical OR (||) Operation that combines two conditions into a single Boolean value that is true when at least one of the conditions is true otherwise it results false.

Assumming the variable score has been assigned the value 9, which of the following statements display xxx?

All of the above i. if(score <= 9); System.out.println("XXX"); ii. if(score > 0 ); System.out.println("XXX"); iii. if(score > 9); System.out.println("XXX");

The style of indenting used in this text is called ____.

Allman style

The individual operations used in a computer program are often grouped into logical units called logistics.

FALSE - it is called procedures - it is a set of operations performed by a computer program which are subdivided into logical parts.

Envisioning program components as objects that are similar to concrete objects in the real world is the hallmark of procedural programming.

FALSE - it is object-oriented programming. (b/c its composed by created the objects from classes in the real world.)

The portion of a program within which you can reference a variable is the variable's ___.

Scope - the scope of a variable is the limit with in we can refer or access variable in a block.

the logical structure in which one instruction occurs after another with no branching is a ____.

Sequence

The method with the declaration public static char procedure(double d) has a method type of char.

True

Usually, you want each instantiate of a class to have its own copy of the data fields (T/F)

True

You cannot place a method within another method.

True

What is the output of the following code segment? t = 10; if(t > 7) { System.out.print("AAA"); System.out.print("BBB"); }

AAABBB

What is the output of the following code segment? t = 0 if(t > 7) System.out.println("AAA"); System.out.println("BBB");

AAABBB

Assuming a variable f has been initialized to 5, which of the following statements sets g to 0?

ALL OF THE ABOVE i. If(f >= 0 || f < 2) g = 0; ii. if(f < 3 || f > 4) g = 0; iii. if(f > 6 || f == 5) g = 0;

Suppose you declare an object as Book myJournal;. Before you store data in myJournal, you ____________.

Also must explicitly allocate memory for it

Which of the following elements is not required in a variable declaration?

An assigned value - to declare a variable in java needed a data type, an identifier (variable) and a semicolon but no need of assigned value. syntax to declare a variable is:(;)

An escape sequence always begins with a(n) _____

Backslash

The body of a class is always written ____.

Between curly braces

Which of the following data types can store the value 0 using the least amount of memory?

Byte

A program or class that instantiates objects of another prewritten class is a(n) ____________.

Class client

Variables that are shared by every instantiation of a class are ___.

Class variables

When data cannot be changed after a class is complied, the data is ____.

Constant - is a quantity that never changed. We can declare a variable as a constant by using the keyword const and the value is not changed after class is compiled. (const PI=3.14;)

Which assignment is correct in Java?

Double value = 2.12;

All Java programming statements must end with a period.

FALSE - must end with a semicolon (;)

In a Java program, you must use forward slashes to separate classes, objects, and methods.

FALSE - must use dots. - dot operator is used to connect the classes with objects or methods. When a dot operator is used all the properties of the class or method can be accessed.

A Boolean variable can hold any character.

FALSE; Boolean is a data type used in java to store the value of true or false only. If the results are true it stores 1 as true, and 0 if it is false.

Assuming a variable y has been assign to the value 6, the value of !(y<7) is ____.

False

in Java, decisions are based on a Boolean Value.

False

You can use the exit statement to terminate a switch statement. (T/F)

False -- break statements allows you to exit a loop from any point within its body

The keyword final used with a variable declaration indicates a static field (T/F)

False, it indicates a symbolic content

An object's data items are also known as ____________.

Fields

If you attempt to add a float, an int and a byte, the result will be a(n) ____.

Float

The concept of allowing a class's private data to be changed only by a class's own methods is known as ____________.

Information hiding

The nonstatic data components of a class often are referred to as the ____________ of that class.

Instance variables

The remainder operator ____.

Is represented by %.

Java supports three types of comments:

Line, block and Javadoc. (Nonexecutable statements in java are comments.)

The most basic circuitry-level computer language is:

Machine language

When a block exists within another blocks, the blocks are __.

Nested

Java is architecturally ___.

Neutral - describes the feature of java that allows you to write programs that can run on any platform.

What is the output of the following code segment? t = 7; if(t > 7) { System.out.print("AAA"); System.out.print("BBB"); }

Nothing

If you use the automatically-supplied default constructor when you create an object, ____.

Numeric fields are set to 0 (zero)

An instance of a class is a(n) ___.

Object

If you create a class that contains one method, and instantiate two objects, you usually store ___ for use with the objects.

One copy of the method

Which of the following method declarations is correct for a static method named displayFacts() if the method receives an int argument?

Public static void displayFacts(int data)

Which of the following could be the last legally coded line of a method declared as public static int getVal(double sum)?

Return 77;

Which of the following is not a primitive data type in Java?

Sector Java has two types of data types: [1) Primitive (boolean, int, and byte) 2) Non-primitive (sector) ]

According to the rules of operator precedence, when division occurs in the same arithmetic statement as ____, the division operations always takes place first.

Subtraction

The rules of a programming language constitutes its:

Syntax

Which java statement produces w on one line and xyz on the next line?

System.out.printIn("w\nxyz");

Languages that let you use an easily understood vocabulary to descriptive terms such as read, write or add, are known as high-level language

TRUE

Nonexecuting program statements that provide documentation are called comments.

TRUE

The code between a pair of curly braces in a method is called a block: (T/F)

TRUE

You save text files containing Java source code using the file extension .java

TRUE

You must compile classes written in Java into bytecode:

True

You use a type case to explicitly override an implicit type.

True

in Java, the value of (14>7) is ___.

True

The value 137.68 can be held by a variable of type float.

True, (It can also be held by double or float.)

Which of the following displays Error when a student ID is less than 1000 or more than 9999?

a. if(stuId < 1000) System.out.println("Error"); else if(stuId > 9999) System.out.println("Error");

Which of the following expressions correctly returns as integer that represents the month of a LocalDate object named hireDate?

hireDate.getMonthValue() [Why? b/c the object hireDate calls getMonthValue() method that returns the integer value to represents the month number of hireDate object.]


Kaugnay na mga set ng pag-aaral

A nemzetállamok és a birodalmi politika kora

View Set

Real Estate Principles | Exam #1

View Set

gvhhhhhhhhhhhhhhhhhhhhh bjkjhhhhhkb b hkb hkbkhj b hkj b hbn bn nb nb bb nb n b bbnnb bn bnnb bn b nbn bn nv vnn v vn nv n vn nv nv nv nvnvnv n v nn nv nv nn nv v nv nv nvnv vnv v n n n bn bnb nnb b bn b b nnb b nbn nb nbnbnbnbbnnbbnbnbnbbnnbnbb

View Set

The Respiratory System ATI Pharmacology Made Easy 4.0

View Set

Food & Human Environment Ch's 1, 2, 3 (Exam 1)

View Set

Hadoop Developer Practice Questions set I 1-250

View Set

Ch. 15 How Humans Evolved Physical Anthropology

View Set