Java Programming Module 1

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

5-What dot operator will allow data to be added to an arrayList?

.add

5-What dot operator will remove all information from an arraylist?

.clear

5-What dot operator will remove specific data from an arrayList either by its position or its value?

.remove

5-What dot operator will allow data to be sorted in an arrayList.

.sort

3-Please match the method to its correct description 1.Retrieves part of a string 2.converts string to lowercase 3.determines if two strings are identical 4.converts strings to uppercase 5.retrieves one character at a particular location 6.gets the length of the string

1. .substring() 2. .toLowerCase() 3. .equals() 4. .toUpperCase() 5. .charAt() 6. .length()

3-Match the operator to the correct definition 1.less than or equal to 2.Ternary 3.remainder operator 4.logical complement operator 5.equality of strings 6.unary minus operator 7.increment operator 8.greater than or equal to 9.conditional-OR 10.equal to 11.decrement operator 12.multiplication operator 13.conditional-AND 14.not equal to 15.assignment operator

1. >= 2. ?: 3. % 4. ! 5. .equals 6. - 7. ++ 8. >= 9. ?? 10. == 11. -- 12. * 13. && 14. != 15.=

4-Match the appropriate loop with the appropriate code. 1 2 3

1.for 2.while 3.do

5-Which of the following is the correct syntax for creating an arrayList?

ArrayList myArraylist = new ArrayList();

5-Which of the following is true; Arraylists have a set size, array lists do not; Arrays have a set size, arraylists do not.

Arrays have a set size, arraylists do not.

5- Which of the following will replace data in a specific array element or elements with a new value?

Arrays.fill

5-Which of the following will allow you to sort an array?

Arrays.sort

6-A(n) ________ is a holding place for bytes that are waiting to be read or written.

ByteBuffer.

7-which statement correctly declares "sedan" object of car class?

Car sedan = new Car();

6-(T or F)Comma-separated values (CSV) is a file format strictly used for working with java and databases.

False.

6-InputStream and OutputStream are subclasses of the _______ class.

Object.

6-When you use java's _______ class to create objects that contain information about files or directories, such as their locations, sizes, creation dates, and whether they even exist.

Path.

6-A _____ is a collection of fields that contain data about an entity.

Record.

3-(T or F)Switch statements work well for menus

True

5-(T or F)An array has a set size that does not grow or contract.

True

5-(T or F)Arrays.binarySearch must be sorted in order to have accurate results.

True

7-(T or F)It is useful to override the parent class members when the superclass data fields and methods are not completely appropriate for the subclass methods.

True

7-(T or F)an interface is created when a developer wants a class to implement behavior from more than one parent.

True

6-(T or F)Java's Path class is used to create objects that contain information about files and directories, while the Files class performs operations on files and directories.

True.

6-(T or F)While System.err and System.out are both directed by default to the monitor command line, System.err is usually reserved for error messages and System.out is reserved for valid output.

True.

6-(T or F)You can store data within a program, but this type of storage is temporary.

True.

6-Any of the file input or output methods in a java program might throw an exception, so all the relevant code in the class in placed in a ________ block.

Try

5-If you are given the following segment of code: a = 2; b = 3; c = 4; myArray [a] [b] = c; What variable represents the rows?

a

5-Which of the following is the correct syntax for assigning a value to a 2-d array declared as int myArray[][]?

a=2; b=3; c=4; myArray[a][b]=c;

5-Which of the following is the correct syntax for retrieving a value out of an array?

a=2; b=3; c=myArray[a][b];

2- in a method call - z = 42; x = myMethod(z); what is z on line 2?

arguements

2-Data items you use in a call to a method are called_________

arguements

5-If you are given the following segment of code: a = 2; b = 3; c = 4; myArray [a] [b] = c; What variable represents the columns?

b

7-Then class used as a basis for inheritance is the ________ class.

base

2-To execute a method, you _________ it from another method

call

2- a method that creates and initializes class objects is also called ____________

constructor

7-When you create a class and do not provide a(n) ____________, Java automatically supplies you with a default one.

constructor

6-Random files are also called _______ files.

direct access.

4-What type of loop will always run once?

do

7-You used the keyword _______ to achieve inheritance in java.

extends

2- (T or F)a method body provides information about how other methods can interact with it.

false

2-(T or F)if an integer is passed to a method with a double parameter, the double is promoted to an integer

false

2-(T or F)variables declared within methods(braces) can be seen and accessed by other methods.

false

2-Methods can only be called by main

false

4-(T of F)When nesting loops, the variable in the outer loop changes more frequently.

false

4-(T or F)All try-catch statements require a finally statement.

false

4-(T or F)The statements that make up a loop body will continue to execute as long as the expression value remains false.

false

5-(T or F)A while loops cannot be used to iterate through an array.

false

5-(T or F)ArrayLists can only store variable?

false

7-(T or F)If a superclass contains only constructors that require arguments, you do not need to create a subclass constructor.

false

4-What type of loop is best when a set number of iterations is known?

for

6-The __________ method returns the last Path element in a list of pathnames.

getFileName()

3-Which of the following is correct?

if(){ }

3-Which of the following will check only for true?

if(){ }

3-Which of the following checks for multiple conditions?

if(){ }else if{ }else{ }

3-Which of the following will check only true or false?

if(){ }else{ }

5-What library is needed in order to use sort, search and fill operations?

import.java.util.Arrays

4-A loop that never ends is called a(n) ___________ loop

infinite

4-How many times will the loop run for the following loop?; double t = 2; for(int cntr = 10; cntr < 100; cntr--){ t=t*2; }

infinite wont stop

4-How many times will the loop run for the following loop? int cntr = 10; double t = 2; while(cntr < 100){ t=t*2; }

infinite-will not run

4-When loops are nested, each pair contains a(n) ____________ loop and an outer loop.

inner

4-Which code will print the following grid? xxxxx xxxxx xxxxx

int column = 0; int row = 0; while (row < 3) { while (column < 5) { System.out.println("x"); ++column; } ++row column=0; System.out.println(""); }

5-Which of the following is the correct syntax for creating an array?

int size = 100; double[] myArray; myArray = new double[size];

4-One execution of any loop is called a(n)______?

iteration

6-When you used the BufferedReader class, you must import the _______ package into your program.

java.io

2-This package contains frequently used classes and is implicitly imported into java programs

java.lang

5-What library must you include in order to sort an arrayList?

java.util.collections;

2-What method executes first in an application no matter where it is placed in the class.

main

2- an object is a _______ of a class

member

7-When you create a class by making it inherit from another class, you are provided with data fields and ________ automatically.

methods

2-In order to allocate memory for an object you use the ________ operator

new

6-You can create a writable file by using the Files class _________ method

newOutputStream()

2-When you think in an object oriented manner, everything is an________

object

2-You have the following: double myMethod1(double z) { double ans = 0; ans = z * 100; return ans; } what is z called?

parameter

2- you pass information into a method through the______

parentheses

7-The term _______ means "many forms".

polymorphism

7-The methods in a subclass can use all the methods and data fields that belong to its parent, with one exception: ___________ members of the parent class are not accessible within a child class methods.

private

2-Name the four types of access modifiers that control access to classes methods or variables.

private, public, protected,

7-Using the keyword _________ provides you with an intermediate sense of security between public and private access

protected

7-In most Java classes, the keyword private precedes each data field, and the keyword _________ precedes each method.

public

7-A(n) ___________ is not an object, but it points to a memory address.

reference

2-You pass information out of a method by__________

return statement

6-Placing a file in the ___ directory of your storage device is equivalent to tossing a loose document in a drawer.

root.

6-The String Class ______ method accepts and argument that identifies the field delimiter and returns an array of strings.

split()

2-(T or F) any class can contain an unlimited number of methods

true

2-(T or F)Methods allow the programmer to break the program into logical pieces. These pieces can be called anytime by any other method including static void main.

true

2-application classes frequently instantiate objects that use the objects of other classes.

true

3-(T or F) Are Breaks are optional for switch statements.

true

4-(T or F)The exception in a try and catch statement can be printed out.

true

5-(T or F)A for loop can be used to iterate through an array.

true

5-(T or F)Arraylists can grow or contract in length as needed.

true

5-(T or F)Arrays can be multi-dimensional

true

5-(T or F)Data can be removed from an arrayList by position.

true

5-(T or F)Data can be removed from an arraylist by value.

true

7-(T or F)A static method cannot be overridden in a subclass

true

7-(T or F)When a protected data field or method is created, it can be used within its own class or in any classes extended from that class; but it cannot be used by outside classes.

true

4-Which of the following is a proper form for a try-catch?

try{ } catch(exception e){ }

4-The process of ensuring that a value falls within a specified range is called ___________.

validating data

2- If a method returns nothing, what is the returned datatype?

void

4-What type of loop will evaluate a condition before running?

while


संबंधित स्टडी सेट्स

MENTAL HEALTH: CHAPTER 12: ABUSE & VIOLENCE

View Set

Alcohol, Drugs and Tobacco Test, my sets

View Set

8A IV Therapy; ATI skills module, pharm book, Igancioius, Article

View Set