Computer Science 1 Java Quiz review

Ace your homework & exams now with Quizwiz!

How do you create a method in Java? methodName. methodName() methodName[] (methodName)

methodName()

How do you insert COMMENTS in Java code? /* This is a comment # This is a comment // This is a comment

//

Java is short for "JavaScript". False True

False

The value of a string variable can be surrounded by single quotes. False True

False

Which data type is used to create a variable that should store text? String Txt myString string

String

What is a correct syntax to output "Hello World" in Java? System.out.println("Hello World"); Console.WriteLine("Hello World"); echo("Hello World"); print ("Hello World");

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

Which method can be used to find the highest value of x and y? Math.maxNum(x,y) Math.maximum(x,y) Math.max(x,y) Math.largest(x,y)

Math.max(x,y)

What is the correct way to create an object called myObj of MyClass? new myObj = MyClass(); class myObj = new MyClass(); class MyClass = new myObj(); MyClass myObj = new MyClass();

MyClass myObj = new MyClass();

How do you call a method in Java? (methodName); methodName[]; methodName; methodName();

methodName();

Which operator is used to multiply numbers? # * x %

*

To declare an array in Java, define the variable type with: () {} []

[]

Which keyword is used to create a class in Java? class() class className MyClass

class

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

The + sign

In Java, it is possible to inherit attributes and methods from one class to another. True False

True

Array indexes start with: 1 0

0

Which operator can be used to compare two values? <> = == ><

==

Which statement is used to stop a loop? return break exit stop

break

Which keyword is used to return a value inside a method? break return void get

return

Which method can be used to return a string in upper case letters? toUpperCase() upperCase() tuc() touppercase()

toUpperCase()

How do you start writing a while loop in Java? x > y while { while x > y { while x > y: while (x > y)

while (x > y)

How do you create a variable with the floating number 2.8? byte x = 2.8f float x = 2.8f; int x = 2.8f; x = 2.8f;

float x = 2.8f;

How do you start writing an if statement in Java? if x > y: if (x > y) if x > y then:

if (x > y)

Which keyword is used to import a package from the Java API library? package lib getlib import

import

How do you create a variable with the numeric value 5? int x = 5; float x = 5; num x = 5 x = 5;

int x = 5;

Which method can be used to find the length of a string? length() getSize() getLength() len()

length()


Related study sets

Honan-Chapter 29: Nursing Assessment: Endocrine Function

View Set

ACSM Chapter 15. 5th.ed Cardiorespiratory Trainig

View Set

VATI Comprehensive Predictor NCLEX Questions

View Set

AP European History Final Review

View Set

Chapter 17: Heart and Neck Vessels Assessment

View Set

Chapter 13: Exercise for Health and Fitness

View Set