Home

Java Online Question

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

Java is short for "JavaScript". (A) True (B) False

How do you insert COMMENTS in Java code? (A) // This is a comment (B) /* This is a comment (C) # This is a comment

Which data type is used to create a variable that should store text? (A) string (B) Txt (C) myString (D) String

How do you create a variable with the numeric value 5? (A) x = 5; (B) float x = 5; (C) int x = 5; (D) num x = 5

How do you create a variable with the floating number 2.8? (A) x = 2.8f; (B) float x = 2.8f; (C) int x = 2.8f; (D) byte x = 2.8f

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

Which operator is used to add together two values? (A) The * sign (B) The & sign (C) The + sign

The value of a string variable can be surrounded by single quotes. (A) True (B) False

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

Java Online Question

Which operator can be used to compare two values? (A) == (B) <> (C) >< (D) =

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

Array indexes start with: (A) 1 (B) 0

How do you create a method in Java? (A) methodName. (B) (methodName) (C) methodName[] (D) methodName()

How do you call a method in Java? (A) methodName; (B) methodName[]; (C) (methodName); (D) methodName();

Which keyword is used to create a class in Java? (A) MyClass (B) class() (C) className (D) class

is the correct way to create an object called myObj of MyClass? (A) class MyClass = new myObj(); (B) new myObj = MyClass(); (C) class myObj = new MyClass(); (D) MyClass myObj = new MyClass();

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

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

Which operator is used to multiply numbers? (A) # (B) x (C) * (D) %

Java Online Question

Which keyword is used to import a package from the Java API library? (A) import (B) getlib (C) package (D) lib

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

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

Which keyword is used to return a value inside a method? (A) void (B) break (C) return (D) get

Which statement is used to stop a loop? (A) return (B) break (C) stop (D) exit