WorksheetsJava Programming
Total questions: 40
Worksheet time: 13mins
JDK stands for (a)
JVM stands for (a)
Which of the following is a comment in the Java language?
/ comment /
/* comment */
/ comment */
<-- comment -->
Which of the following is the correct main() method signature in Java?
public static void main (String [] args)
public static void Main (String [] args)
public static void main (string [] args)
public static void main (String args)
Which of the following is a valid variable declaration in Java?
int 1myInteger = 0;
int int = 0;
Int my Integer = 0;
int myInteger = 0;
Which Java data type is used to store 64-bit floating-point numbers?
int
long
float
double
The import statement used in Java to access the Scanner class is:
import java.Scanner;
import java.util.Scanner;
import java.package.Scanner
import.java.util.Scanner;
What is pseudocode?
A simple java-like programming language
Statements in plain English
A control structure used in Java
A java class
What is a class in object-oriented programming?
A class is a template with data and methods
A class is a package
A class is the declared object in memory
A class is a reference object in memory
Which of the following is a reserved word in Java?
export
import
input
output
Which of the following is not a Java features?
Dynamic
Architecture Neutral
Use of pointers
Object-oriented
According to you, what is Java? Choose two applicable answers.
A mediator between you and your computer
A programming language
An island
A video game console
Which of this command is the correct way of printing in Java?
System.Out.print
System.out.Print
System.out.print
system.out.print
Which of this command has errors? Select multiple
System.out.print("Hello World")
System.out.print(Hello World);
System.out.Print("Hello World);
System.out.print("Hello World");
It is an optional statement used to describe what a program or a line of program is doing.
tag
command
code
comment
A data type which is typical in form and make use of digits and a decimal point
integer
float
char
boolean
What data type is classified as a sequenced of characters with double quotes.
Char
String
boolean
Float
True or False : Java is case sensitive, which means identifier Hello and hello would have different meaning in Java
True
False
What is the output for the following statement:
System.out.print("1"+"1");
11
2
Error Message
Indicate the actual output of the statements below:
int thisYear = 2020;
System.out.println("The current year is "+thisYear);
The current year is thisYear
The current year is 2020
No output; an error exists
The current year is
Which of the following is used as a terminator in Java programming?
)
;
.
>
int x= 10;
int y = 20;
int z = x + y;
System.out.println(z);
Guess the output.
1020
10 20
30
"10 20"
Predict the output of the following program.
class A{
int a=40;//non static
public static void main(String args[]){
System.out.println(a);
}
}
Compilation Error
40
0
None of the above
what is the output of this question?
class Test1 {
static int x = 10;
public
static void main(String[] args)
{
Test1 t1 = new Test1();
Test1 t2 = new Test1();
t1.x = 20;
System.out.print(t1.x + " ");
System.out.println(t2.x);
}
}
10 10
20 20
10 20
20 10
What is the output of this question?
class Test1 {
static int i = 1;
public static void main(String[] args)
{
for (int i = 1; i < 10; i++) {
i = i + 2;
System.out.print(i + " ");
}
}
}
3 6 9
3 6 9 …. 27
Error
none
What is the output of this question?
class Test1 {
static int i = 1;
public static void main(String[] args)
{
int i = 1;
for (Test1.i = 1; Test1.i < 10; Test1.i++) {
i = i + 2;
System.out.print(i + " ");
}
}
}
1 3 9
1 2 3 … 9
3 5 7 9 11 13 15 17 19
None
Keywords like final cannot be used as identifiers because they are the reserved keywords. True or False?
True
False
ar, given the following declaration:int[] ar = {2, 4, 6, 8 }0, 1, 2, 31, 2, 3, 40, 2, 4, 6int [] nums = {2, 3, 5, 8, 9, 11};
How would you access the fourth element in nums?
nums[4]
nums[3]
nums(4)
nums(3)
Insertions within the code that explain the purpose of the code statements.
Algorithms
Requirements
Comments
Solutions
In object-oriented terminology, the characteristics of an object are defined by its ____.
attributes
class
instance
methods
______is the capability of an object to have data functionality available to the user without the user having to understand the implementation within the object.
Polymorphism
Aggregation
Encapsulation
Inheritance
A console application uses a graphical user interface.
True
False
A ______ should always start with an uppercase first letter.
Object
Class
Variable
Array
Is the entry point into the application.
Public
Static
Void
main()
It marks the beginning and the end of a block of code.
{}
()
[]
<>
Which of the following is an INCORRECT syntax in Java Programming?
int num1 = 15;
int num1;
num 1 = 15;
double num1 = 3.14d;
num1 = 15;
Identifier Names are case sensitive ("myVar" and "myvar" are different variables)
Yes
No
Maybe Yes
Maybe No
It Increases the value of a variable by 1
+
++
/+
/++
