Java Programming Final

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

Which operator can be used in string concatenation? * ++ += =+

+=

Which of the following is not an arithmetic operator? + . _ %

.

How do you insert comments in java? /This is a comment //This is a comment */This is a comment

//This is a comment

Each of the following is a relational or equality operator except ________ == <= =! >

=!

Which operator is used to add together two values? The + sign The * sign The & sign

The + sign

Which statement below is false? Structured programming produces programs that are easier to test. Structured programming produces programs that are easier to modify Structured programming requires four forms of control Structured programming promotes simplicity

Structured programming requires four forms of control

Which of the following is not a superclass/subclass relationship? Employee/Hourly Employee Vehicle/Car Sailboat/Tugboat

Sailboat/Tugboat

Which of the following is not a java primitive type? char byte real

real

A constructor cannot ___________. specify return types or return values have the same name as the class be overloaded

specify return types or return values

Which of the following statements is true? The catch block contains the code that might throw an exception. You can have many catch blocks to handle different types of exceptions. The try block contains the code that handles the exception if one occurs.

You can have many catch blocks to handle different types of exceptions

A(n) __________ class cannot be instantiated. abstract concrete final polymorphic

abstract

The parameter list in the method header and the arguments in the method call must agree in __________. number order type All of these

all of these

Interfaces can have _______ methods 0 1 2 any number of

any number of

Instance variables declared final do not or cannot _______. cause syntax errors if used as a left-hand value. be initialized. be modified after they are initialized. none of these.

be modified after they are initialized

Assigning a subclass reference to a superclass variable is safe ______________. because the subclass object has an object of its superclass only when the superclass is abstract because the subclass object is an object of its superclass

because the subclass object is an object of its superclass

Which primitive type can hold the largest value? long float double int

double

Which expression is equivalent to if (!(grade == sentinelValue))? ! if (grade == sentinelValue) if (grade != sentinelValue) if (grade !== sentinelValue) ! if (grade !== sentinelValue)

if (grade != sentinelValue)

Which of the following is a variable declaration statement? import java.util.Scanner; public static void main( String args[]) int total; // first string entered by user

int total;

Inheritance is also known as the __________. knows-a relationship is-a relationship uses-a relationship

is-a relationship

Overriding a method differs from overloading a method because _________. Overloaded methods have the same signature Overridden methods have the same signature Neither of those

overridden methods have the same signature

Superclass methods with this level of access cannot be called from subclasses. protected public private

private

Information is passed to a method in ________. the method name that method's return the arguments to the method

the arguments to the method

End-of-line comments that should be ignored by the compiler are denoted using ________ two forward slashes (//) a slash and a star (/*) three forward slashes (///) a slash and two stars (/**)

two forward slahses (//)

To exit out of loop completely, and resume the flow of control at the next statement after the loop, use a ________. continue statement return statement break statement any of these

break statement

Non-abstract classes are called _________. concrete classes implementable classes real classes

concrete classes

Java requires a ________ call for every object that's created. destructor parameterless constructor

constructor

Keyword ________ indicates the inheritance relationship. inherits super extends parent

extends

Which of the following will count down from 10 to 1 correctly? for (int j=10; j>1; j--) for (int j=10; j>=1; j--) for (int j=1; j<=10; j++)

for (int j=10; j>=1; j--)

Composition is sometimes referred to as a(n)__________. many-to-one relationship is-a relationship has-a relationship one-to-many relationship

has-a relationship

Which of the following is true? A performing a task in a program requires a method A method houses the program statements that acutally perform its task All of these

All of these

Which statement is false? A class is an inheritance of its object A class is to an object as a blueprint is to a house Classes are reusable software components Performing a task in a program requires a method

A class is an instance of its object

Which of the following statements is true? Interpreted programs run faster than compiled programs Interpreter programs typically use machine language as input Compilers translate high-level language programs into machine language code None of these

Compilers translate high-level language programs into machine language code

Which of the following statements is true? Private members of a class are directly accessible to clients of a class. Not declare a method private in programs that include addition calculations. Methods and instance variables can both be either public or private. None of these is true.

Methods and instance variables can both be either public or private

All import declarations must be placed ________ inside the class declaration's body before the class declaration after the class declarations all of these will work

before the class declaration

What is the correct syntax to output "Hello world" in java System.println("Hello World"); Echo("hello World"); System.out.println("Hello World");

System.out.println("Hello World");

Declaring a method final means _________. it will prepare the object for garbage collection it cannot be overriden it cannot be accessed from outside its class

it cannot be overridden

Which of the following is not a type of repetition statements in Java? loop statement do...while statement while statement for statement

loop statement

The identifiers in an enumeration _________. may be duplicated must be uppercase letters and cannot contain numbers must be lowercase letters and cannot contain numbers must be unique

must be unique

Which of the following is not a valid java identifier? $_AAA1 width my Value m_x

myValue

Which of the following statements is true? A while statement cannot be nested inside another while statement. A while statement cannot be nested inside an if statement An if statement cannot be nested inside another if statement. None of these is true

none of these are true

Declaring instance variables ________ is known as data hiding or information hiding. secure masked private

private


Set pelajaran terkait

APUSH Essay Questions and Answers

View Set

Chapter 11: Essential Peripherals

View Set

Financial Accounting II - Chapter 13 - Exam 3 Review

View Set

EMT104 Chapter 7 Navigate 2 Quiz

View Set

Epidemiology & Evidence Based Medicine

View Set

Chapter 17 Intermediate Accounting: Questions

View Set