Java - Final Exam

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

--

Decrement Operator

%=

Divides a variable by the value of the right operand and assigns the remainder to the variable.

/=

Divides left operand by the right and assigns the value to the left operand.

Length

Each array in Java has a public field named ____ that contains the number of elements in the array.

Iteration

Each repetition of a loop is known as what?

Infinite loop

If a loop does not contain within itself a way to terminate, its called an _____.

0 though 14

If final int SIZE = 15 and int[] x = new int[SIZE], what would be the range of subscript values that count be used with x[]?

Information hiding

In Java, the concept of keeping data private is known as______.

String myString = "Whatever"; or String myString = newString("Whatever");

Java code to declare a variable of type String and initialize it to "whatever".

double dArray[] = new double[497];

Java code to declare and allocate an array with 497 elements of type double.

Array Bounds Checking

Java performs _____, which means that it does not allow a statement to use a subscript that is outside the range of valid subscripts for the array.

int array[][] = new int[4][5];

Java statement that declares and allocates a 2-dimensional array of integers with four rows and five columns.

-+

Subtracts right operand from the left and assigns the result the left.

PrintF

System.out.printf("it is an integer: %d%n", 1000");

Protected

The code is accessible in the same package and subclasses.

Private

The code is only accessible within the declared class.

Java API

The exception classes are in packages in the _____.

Java Virtual Machine

a program that executes compiled java code on a specific platform.

UML Diagram

Arrows used in a ____ to show inheritance relationships extend from the descendant class and point to the original class.

Data Type

By convention, a class diagram contains the _____ following each attribute or method.

Non-Static

Can access any static method and static variable, without creating an instance of the object

MyClass myObject = new MyClass("Hello");

Code to create an object named myObject by instantiating a class called MyClass and passing the constructor a String literal "hello" as the argument.

>

Greater Than

Polymorphism

In Java, using the same method name to indicate different implementations is called ______.

I

In a multi-catch, the exception types are separated in the catch clause by this symbol:

++

Increment Operator

<

Less Than

=<

Less than or equal to

*=

Multiply AND. Multiplies left operand by right and assigns product to left operand.

int iArray[] = {97, 33, 44, 12}

Show one line of Java code that declares, allocates, and initializes an array of type integer with exactly 4 elements whose values are 97, 33, 44, and 12, in that order.

Extends

The Java keyword that creates inheritance is______.

Data Type, Variable Name, Initial Value, Semicolon

The Java variable declaration creates a new variable with required properties. The programming language requires four basic things to declare a variable in a program.

Base

The class used as a basis for inheritance is the ____ class.

Subscript

What do you call the number that is used as an index to pinpoint a specific element within an array?

Object-oriented

What type of language is Java

Run-time

When a java program throws an exception because it cannot open a file.

Default

When no access modifier is specified for a class, method, or data member.

import java.io.*;

When using the PrintWriter class, which of the following import statements would you write near the top of your program?

Dog/Poodle

Which of the following choices is the best example of a parent class/child class relationship?

Extends

You use the keyboard ____ to achieve inheritance in Java.

Subtype

_____ polymorphism is the ability of one method to work appropriately for subclasses of the same parent class.

Super Class

a general class and the subclass are the specialized class

Constructor

is a block of code that initializes the newly created object. It resembles an instance method but it's not a method as it doesn't have a return type.

Inheritance

is a mechanism that enables one class to acquire all the behaviors and attributes of another class.

Println

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

Print

public void print(String s)

Event Driven Programming

when a program is designed to respond to user engagement in various forms. It is known as a program paradigm in which the flow of program execustion is determined by "events". Events are any user interaction, such as a click or key press, in response to prompt from the system.

for (int i = 0; i < iArray.length; i++) { iAverage += iArray[i]; } iAverage /= iArray.length

A loop that computes the average of an array of integers called iArray that has been previously declared and initialized. Store the result in a variable type integer called iAverage that has been previously declared and initalized to zero.

Ragged Array

A two-dimensional array where the rows are of different lengths

Search Algorithm

A way to locate a specific item in a larger collection of data.

+=

Add AND adds right operand to the left and assigns the result to the left.

Public

Functions and variables can be accessed by all parties within and outside the contract.

=>

Greater than or equal to

Finally

The try statement may have an optional ____ clause, which must appear after all of the catch clauses.

Static

They are convienient for many tasks because they can be called directly from the class, as needed. They are most often used to create a utility class that perform operations on data, but have no need to collect and store data.

Loop

This is a control structure that causes a statement or group of statements to repeat.

Exception Handler

This is a section of code that gracefully responds to exceptions when they are thrown.

Sentinel

This is a value that signals when the end of a list of values has been reached.

Post-test loop

This type of loop will always be executed at least once.

Loop Control Variable

This variable controls the number of times that the loop iterates.

Scanner

To create an object of a scanner class, we usually pass the predefined object. System.in, which represents the standard input stream. We may pass an object of a class file if we want to read input from a file. Example: Scanner input = new Scanner(System.in);

Constant

To make any variable a constant, we must use 'static' and 'final modifiers in the following manner: static final datatype identifer_name = constant;

Override

Sometimes the superclass data fields and methods are not entirely appropriate for the subclass objects; in these cases, you want to ____ the parent class members.

0

Subscript numbering always starts at what value?

Three

When you create parent and child classes of your own, the child classes use ____ constructors.

Information hiding

When you employ _____, your data can be altered only by the methods you choose and only in ways that you can control.

import java.io.File; import java.util.Scanner; public class ReadFromFileUsingScanner { public static void main(String[] args) throws exception { File file = new File("C:\\Users\\Katelyn\\Desktop\\Test.txt"); Scanner sc = new Scanner(file); while (sc.hasNextLine()) System.out.println(sc.nextLine()); } }

Write Java Statement to open a textfile for reading

ClassName object = new ClassName();

Write a Java statement to create an object:

Final

You can use the ____ modifier with methods when you don't want the method to be overridden.

Inline

A compiler can decide to _____ a final method; that is, determine the code of the method call when the program is compiled.


Conjuntos de estudio relacionados

Chapter 24: Nursing Care of the Child With an Alteration in Cellular Regulation/Hematologic or Neoplastic Disorder

View Set

Communication Skills for the Workplace

View Set

Network+ Chapter 2: Network Infrastructure and Documentation

View Set

Lesson 1: Business Driven Technology

View Set

OPS/330T: Strategic Operations And Logistics Topic 8 Quick Check

View Set