Test 3 Review Questions

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

What are the values of an array called?

elements

What are overload methods?

enables you to define methods with the same name as long as their signatures are different (different parameters)

Formal parameters and actual parameters must match in what?

number, order, and data type

What is a void method, does a void method have a return statement?

performs an action no return value

How do you write a class in Java (data fields, constructors, and methods)? private vs public?

private- the member cannot be accessed by code outside the class public- the member can be accessed by code inside or outside the class

How do you call a method from the same class? From a different class?

returnDataType variable = methodName (actual parameters) ClassName.methodName (actual parameters)

Using sample as your array name, how can you represent the length of the array?

sample.length

What is scope? What is a local variable?

scope- the part of the program where the variable can be referenced local- a variable defined inside a method

What is the difference between pass by value and pass by reference? How does Java pass arrays and primitive data types?

value- passes arguments to a method reference- affects the original array that was passed as the argument arrays- reference is passed to the method primitive- actual value is passed

What is the position of a value in an array called?

array index

How to invoke an anonymous array?

new dataType [ ] {literal0, literal1, ..., literalk};

How is a constructor named? What is its return type?

ClassName objectName = newClassName()

How to copy an array using a loop or System.arraycopy(...) method?

System.arraycopy(sourceArray, source_position, targetArray, target_position, length);

What is a method? The syntax for a method header?

a collection of statements that are grouped together to perform an operation modifier returnValueType methodName(list of parameters)

What is an array? How to declare and create an array?

a data structure that represents a collection of the same types of data dataType [ ] arrayRefVar = new dataType [arraySize];

Print all elements in an array named integers. How to use a for-each loop to do it?

for (integer: integers) { System.out.println(value); }


Ensembles d'études connexes

Загальноприродничі та екологічні закони (питання №8)

View Set

Combo with "NBME 11 Notes" and 9 others

View Set

Agile Software Development - Scrum

View Set

speed, velocity, acceleration, Newton's Second Law.

View Set

Biology Study Guide- Diffusion, Concentration Gradients, Osmosis, Active Transport, Endocytosis, and Exocytosis

View Set