Worksheetsjava Quiz
Total questions: 24
Worksheet time: 35mins
The keyword "method" is another name for
an object
a class
a function
a variable
Which of the following is NOT a numeric data type
int
double
float
decimal
Which of the following is incorrect?
int count = 50.0;
int salary = 50_000;
int salary = 50_00;
all of these are incorrect
Which of the following is an example of a reference variable declaration?
int count;
String name;
float gpa;
char firstInitial;
Where does a java program start executing instructions from:
class
source file
main method
object
#Number sign
; Semicolin
) Close parenthesies
>Less than
int len = "jump it!".length();
What is the value of len?
8
7
9
6
This code does not compile.
Which keyword is used to create an object in Java?
create
object
new
make
What does the following print out?
int a = 10;
a += 5;
a *= 2;
a++;
System.out.println(a);
10
21
31
20
30
Which one is the proper format for a multi-line comment in Java?
//
Hello
World
//
*/
Hello
World
/*
/*
Hello
World
*/
There's no such thing
--------- is a symbol, that operates on operands and produce a result
operands
variables
operators
Ternary
Which of the following creates an object of Main class?
Main obj = new Main;
Main obj = new Main();
Main obj = new Mian();
Main obj == new Main();
What type of language is Java?
Object Oriented
Scripting
Assembly
Pseudocode
How do you properly extend a class?
public class extends class
private class2 extends class
public class2 extends class
private class2 extends class
public class Box
{
int width;
int height;
int length;
public Box(int w, int h, int l){
//constructor code here}
}
class mainclass
{
public static void main(String args[])
{
Box obj1 = new Box();
Box obj2 = new Box();
obj1.height = 1;
obj1.length = 2;
obj1.width = 1;
obj2 = obj1;
System.out.println(obj2.height);
}
}
What is printed out?
1
2
Runtime error
There is no value printed out
In Java null is:
The initial value of an object variable.
A key word
A value that means not pointing to any object
All of these
None of these
Which type of data is used to enter the value (1234.5)?
Integer
double
char
void
The string method length() returns what?
The size in memory of the string
The number of symbols in a string
How long the biggest word is
A measurement of how long the program has run
What will be the output of the code give below:
class yes
{
public static void main(String[] args)
{
int Integer = 24;
char String = 'I';
System.out.print(Integer);
System.out.print(String);
}}
24I
24
I24
24
I
What do you use to compare two strings' contents?
==
=
.equals()
.isEqual()
