W3Reference.com
Toggle Menu
Home
Online Rust Compiler
Tutorials
Python Tutorial
Java Tutorial
Rust Tutorial
TypeScript Tutorial
ReactJS Tutorial
HTML & CSS Basics
Docker Containers Guide
Kubernetes Tutorial
Software Design Patterns
Blog
All Posts
Java Basics for Beginners
Review your understanding of Java syntax,data types,and control structures.
1. Which of the following is a primitive data type in Java?
String
int
ArrayList
Object
2. Which access modifiers are available in Java?
public
private
protected
internal
default (no modifier)
3. Java is a case-sensitive language.
True
False
4. What symbol is used to denote a single-line comment in Java?
5. What is the correct signature for the main method in a Java program?
public static void main(String args)
public void main(String[] args)
public static void main(String[] args)
static public void Main(String[] args)
6. Which loop structures are supported in Java?
for
while
do-while
repeat
loop
7. Primitive data types in Java can hold the value 'null'.
True
False
8. What keyword is used to create an instance of a class?
9. Which operator is used for logical AND in Java?
&
&&
|
||
10. Which statements can exit a loop prematurely?
break
continue
return
exit
stop
11. Method overloading allows multiple methods with the same name but different parameters.
True
False
12. What is the default value of an uninitialized boolean variable?
13. How do you correctly declare an array of integers in Java?
int[] numbers;
int numbers[];
Both A and B
int numbers[5];
14. Which of the following are Java keywords?
class
interface
enum
struct
goto
15. Static members belong to the class, not individual instances.
True
False
16. What is the output of: System.out.println(3 + 4 * 2);
17. Which keyword is used to inherit a class in Java?
extends
implements
inherits
super
18. Which method returns the length of a String?
length()
size()
getLength()
length
size
19. Java is a purely object-oriented programming language.
True
False
20. What does JVM stand for?
Reset
Answered 0 of 0 — 0 correct