WorksheetsJava Programming Language.
Total questions: 45
Worksheet time: 23mins
Java is a ________, object-oriented, and platform-independent programming language developed by Sun Microsystems in 1995 (now owned by Oracle).
high-level
low-level
machine-level
assembly-level
Who developed Java in 1995?
Microsoft
Sun Microsystems
Oracle
IBM
Java is designed to be simple, secure, and portable, following the principle of "write once, run anywhere" through the use of the ________.
Java Virtual Machine (JVM)
Java Development Kit (JDK)
Java Runtime Environment (JRE)
Java Compiler
The principle of "write once, run anywhere" in Java means:
Java programs can run on any platform without modification.
Java code must be rewritten for each operating system.
Java applications only run on Windows systems.
Java programs require platform-specific compilers.
Which programming concepts does Java support that make it suitable for building modular and reusable code?
Procedural programming concepts
Object-oriented programming concepts
Functional programming concepts
Logic programming concepts
Fill in the blank: Java is widely used in ________, web development, enterprise systems, mobile apps (Android), and cloud-based solutions.
desktop applications
game consoles
smart TVs
wearable devices
What are some reasons for Java's popularity according to the passage?
Robust standard libraries, automatic memory management (garbage collection), and strong community support
Limited libraries, manual memory management, and weak community support
Complex syntax, slow performance, and poor documentation
Lack of versatility and reliability
Fill in the blank: One of the key features of Java is that it is ________ & Easy to Learn.
Simple
Complicated
Obscure
Difficult
Fill in the blank: Java is ________-Oriented and supports classes, inheritance, polymorphism, etc.
Object
Procedure
Function
Logic
Fill in the blank: Java is ________-Independent and runs on Windows, Mac, Linux, Android, etc.
Platform
Language
Device
Network
Fill in the blank: Java is Secure & ________ and provides automatic memory management and strong typing.
Robust
Fragile
Unstable
Weak
Fill in the blank: Java is ________ and supports concurrent programming.
Multithreaded
Single-threaded
Non-threaded
Unthreaded
Refer to the Java 'Hello World' program shown in the image. What will be the output when this program is executed?
A) Hello, World!
B) Hello World
C) HelloWorld
D) Error
Refer to the Java 'Hello World' program shown in the image. The programming language used in the code is:
Java
Python
C++
JavaScript
Fill in the blank: Data types define the kind of ______ a variable can store.
data
function
loop
operator
In Java, every variable must be declared with a data type.
True
False
What are the two main categories of data types in Java?
Primitive and Non-Primitive (Reference)
Integer and String
Static and Dynamic
Local and Global
Fill in the blank: The two main categories of data types in Java are ______ Data Types and Non-Primitive (Reference) Data Types.
Primitive
Object-Oriented
Composite
Functional
What is the range of values for the 'byte' data type in Java?
-128 to 127
0 to 255
-255 to 255
-127 to 128
Primitive types are the basic building blocks in Java. They store simple values directly in memory. Which primitive data type in Java is a 16-bit integer?
byte
short
int
long
Primitive types are the basic building blocks in Java. They store simple values directly in memory. Which primitive data type is most commonly used for 32-bit integers in Java?
byte
short
int
long
Primitive types are the basic building blocks in Java. They store simple values directly in memory. Which primitive data type in Java is used for big numbers and is a 64-bit integer?
byte
short
int
long
Primitive types are the basic building blocks in Java. They store simple values directly in memory. Which primitive data type in Java is a 32-bit decimal and stores approximate values?
float
double
int
long
Classes & Objects are ________ data types.
user-defined
primitive
built-in
abstract
Which of the following is NOT an example of a non-primitive data type?
String
Array
Integer
Classes & Objects
Non-primitive data types store references to memory locations.
True
False
Unlike primitive types, non-primitives can have ________ and are created using constructors.
methods
values
loops
keywords
What is a variable?
A variable is a name given to a memory location that stores data.
A variable is a type of function that performs calculations.
A variable is a fixed value that cannot be changed.
A variable is a graphical representation of data.
Fill in the blank: A ________ is a name given to a memory location that stores data.
variable
function
operator
constant
How can you think of a variable?
Like a box with a label where you can keep values.
Like a locked door that cannot be opened.
Like a number that never changes.
Like a finished book that cannot be edited.
In Java, every variable has a ______ (what kind of data it can hold).
type
method
class
object
Which of the following is a valid way to begin a variable name according to the rules for naming variables?
With a number
With a letter
With a space
With a reserved keyword
A variable name can start with a number according to the rules for naming variables.
True
False
Fill in the blank: According to the rules for naming variables, you should use ________ for variable names (e.g., studentName, accountBalance).
camelCase
snake_case
PascalCase
kebab-case
Which of the following is NOT allowed in variable names according to the rules for naming variables?
Spaces
camelCase
Letters
Underscore (_)
In Java, you must declare a variable before using it.
True
False
Fill in the blank with the correct syntax for declaring a variable in Java: ______ variableName = value;
dataType
varType
typeOf
variableType
What is the value assigned to the variable 'age' in the following declaration?
20
18
25
30
What is the data type of the variable 'height' in the following declaration?
double
int
char
float
Is the following variable declaration syntactically correct in Java? #String name = "Ama";
True
False
Which of the following Java code snippets correctly stores your name, age, and GPA, and prints them using System.out.println()?
String name = "John"; int age = 20; double gpa = 3.5; System.out.println(name + " " + age + " " + gpa);
String name = 20; int age = "John"; double gpa = "3.5"; System.out.println(name + age + gpa);
String name = "John"; int age = 20; double gpa = 3.5; System.out.print(name, age, gpa);
String name = "John"; int age = 20; double gpa = 3.5; System.out.println(name, age, gpa);
What are operators used for in Java?
To perform operations on variables and values
To store data
To create classes
To define methods
Which of the following is NOT a type of operator supported by Java?
Arithmetic
Logic
Comparison
Assignment
Inheritance
Fill in the blank: Operators are ______ used to perform operations on variables and values.
symbols
numbers
letters
words
Fill in the blank: One type of operator in Java is _________.
Arithmetic Operators
String Operators
Loop Operators
Array Operators
