CS212

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

What is the extension of a file produced from source code by the Java compiler?

.class

In the Java programming language, all source code is first written in plain text files ending with what extension?

.java

In the Java statement "int x;" if x is an instance variable of the class, its default value of will be

0

If the variable y is declared as an instance variable in a class as follows: "float y;" the default value of y is

0.0f

If the Java class TryMe.class is run using the following command: "c:> java TryMe 1 2 3" What would be output of the following statements in the main method: System.out.println(args[0]+args[1]+args[2]);

123

The primitive type short is stored using how many bits?

16

Type char contains

16-bit Unicode characters

If the Java class TryMe.class is run using the following command: "c:> java TryMe one two three" What is the length of the array args[] in the main program?

3

If the array myArray is declared as int[][] myArray = {{2,3,4,5},{3,4,5,6},{4,5,6,7}}What is the value of myArray.length?

3

If the array myArray is declared as int[][] myArray = {{2,3},{3,4},{4,5}}How many rows and columns does it have?

3 rows, 2 columns

The primitive type int is stored using how many bits?

32

If the array myArray is declared as int[][] myArray = {{2,3},{3,4,5,6},{4,5,6}}What is the value of myArray[1].length

4

If the array myArray is declared as int[][] myArray = {{2,3},{3,4},{4,5}}What is the value of myArray[1][1]?

4

In the statement int p[] = {2,4,6,8} the length of p is:

4

What will be the output of this program segment: int p[] = {2,4,6,8}; System.out.println(p[1]);

4

What is the correct command to compile the program HelloWorld.java?

C:>javac HelloWorld.java

If a Java class is declared as: public class HelloWorld {} then the name of the file it is saved in must be

HelloWorld.java

Java .class files must be run by the

Java Virtual Machine

Which is the correct way to instantiate a new TextFileInput object?

TextFileInput tfi = new TextFileInput("myFile.txt");

What are the two main components of the Java language?

The Java Virtual Machine (JVM) and the Application Programming Interface (API)

What will be the result of the following statement: int i = Integer.parseInt("45");

The variable i will get the integer value 45

The statement: "int[] x;" indicates

There is a variable x that will contain a reference to an array object which contains integers

Match the following advantages of Java to the appropriate reason for the advantage. Get started quickly: Although the Java programming language is a powerful object-oriented language, it's easy to learn, especially for programmers already familiar with C or C++. Write better code: The Java programming language encourages good coding practices, and automatic garbage collection helps you avoid memory leaks. Avoid platform dependencies: You can keep your program portable by avoiding the use of libraries written in other languages. Write once, run anywhere: Because applications written in the Java programming language are compiled into machine-independent bytecodes, they run consistently on any Java platform. Develop programs more quickly: The Java programming language is simpler than C++, and as such, your development time could be up to twice as fast when writing in it. Your programs will also require fewer lines of code.

Yes

If the variable c is declared as an instance variable in a class as follows: "char c;" the default value of c is

\u0000

Consider the following segment of Java code. What will be the output? String cat = "Cat"; System.out.println(cat.charAt(1));changeCat(cat); System.out.println(cat.charAt(1));-----------------------------------public static void changeCat(String dog) {dog = "Cut";

a a

An array is

a container object that holds a fixed number of values of a single type

The Java Application Programming Interface (API) is

a large collection of ready-made software components

A platform is the hardware or software environment in which a program runs. Most platforms can be described as a combination of the operating system and underlying hardware. The Java platform differs from most other platforms in that it's

a software-only platform

f the class equalStrings.class is run using "c:> java equalStrings cat dog cat rat dog" Which of the following statements will be true? a.) equals(args[0],args[2]) b.) args[0] < args[1] c.) args[0].equals(args[2]) d.) args[0] == args[2]

args[0].equals(args[2])

What are the contents of a .class file in Java?

bytecodes

What is the correct command to run the class HelloWorld.class?

c:>java HelloWorld

The length of an array

cannot be changed once it is declared

Which of the following is not an integer format?

float

If the array myArray is declared as int[][] myArray = new int[3][4];Which of the following loops will set all the cells of the array equal to 10?

for (int i=0; i<myArray.length; i++) for (int j=0; j<myArray[i].length) myArray[i][j] = 10;

If the Java class TryMe.class is run using the following command: "c:> java TryMe one 2 three" Which of the following statements will cause an error? int i = Integer.parseInt(args[0]); int i = Integer.parseInt(args[1]); Neither Both

int i = Integer.parseInt(args[0]);

What is the name of the method that is run first when a Java application is launched?

main

If the variable s is declared as an instance variable in a class as follows: "string s;" the default value of s is

null

Exceptions in Java are

objects

If the Java class TryMe.class is run using the following command: "c:> java TryMe one two three" What would be the output of the following statement in the main method: for (int i=0; i<args.length; i++)System.out.print(args[i]);

onetwothree

If the Java class TryMe.class is run using the following command: "c:> java TryMe one two three" What would be the output of the following statement in the main method: for (int i=0; i<args.length; i++) System.out.print(args[i].charAt(i));

owr

Assertions are used during --?-- and exceptions are used during --?--.

program development, program execution for users

What is the correct signature of the main method?

public static void main(String[] args)

Which of the following methods is contained in the class TextFileInput?

readLine()

A variable that will contain an integer value no greater than 32,767 would best be stored in which type?

short

Which of the following is not a Java Development Tool? javadoc - the java documentation producer the JVM javac - the java compiler java - the java launcher

the JVM.

Suppose in the following program segment, x is supposed to be less than 5. Which of the following is the correct code for <statement A> so that an exception is thrown if that is not the case: if (! x<5) <statement A>

throw new IllegalArgumentException("x must be < 5");

If the Java class TryMe.class is run using the following command: "c:> java TryMe one two three" What would be the contents of args[1] in the main program.

two

In Java, primitive parameters are passed by --?-- and object parameters are passed by --?--.

value, reference

The length of an array is established

when the array is created


Conjuntos de estudio relacionados

Psychiatric-Mental Health Practice Exam HESI

View Set

What three structures make up the bacterial cytoskeleton and what are they used for? Which are used in eukaryotic flagella? Which are used in pseudopodia motility?

View Set

Texas Promulgated Contract Forms: Ch. 7 Quiz

View Set

TOPIC 2 - THE HISTORY OF PSYCHOLOGY

View Set