Basics Of Java Flashcards
What is Java?
Java is a high-level, object-oriented programming language designed for portability and ease of use.
True or False: Java is a platform-independent language.
True
Fill in the blank: Java was developed by ________.
Sun Microsystems
What is the Java Virtual Machine (JVM)?
The JVM is an abstract computing machine that enables a computer to run Java programs.
What is the main method signature in Java?
public static void main(String[] args)
What does JDK stand for?
Java Development Kit
What is the purpose of the JRE?
Java Runtime Environment is used to run Java applications.
What are Java bytecodes?
Java bytecodes are the compiled format of Java source code that can be executed by the JVM.
Which keyword is used to create a class in Java?
class
True or False: In Java, every class must be defined in a separate file.
False
What is encapsulation in Java?
Encapsulation is the bundling of data and methods that operate on that data within one unit, restricting access to some of the object’s components.
What does the ‘this’ keyword refer to in Java?
‘this’ refers to the current instance of the class.
What is inheritance in Java?
Inheritance is a mechanism where one class can inherit fields and methods from another class.
What is polymorphism in Java?
Polymorphism allows methods to do different things based on the object that it is acting upon.
What is an interface in Java?
An interface is a reference type in Java that can contain only constants, method signatures, default methods, static methods, and nested types.
What is the purpose of the ‘final’ keyword?
The ‘final’ keyword is used to declare constants, prevent method overriding, and prevent inheritance.
What are the primitive data types in Java?
The primitive data types in Java are byte, short, int, long, float, double, char, and boolean.
What is the difference between ‘== ‘and ‘.equals()’ in Java?
’==’ checks for reference equality, while ‘.equals()’ checks for value equality.
What is a constructor in Java?
A constructor is a special method that is called when an object is instantiated.
What is exception handling in Java?
Exception handling is a mechanism to handle runtime errors, allowing the normal flow of the program to continue.
What is the purpose of the ‘try’ block?
The ‘try’ block is used to wrap code that might throw an exception.
What is the difference between ‘throw’ and ‘throws’?
‘throw’ is used to explicitly throw an exception, while ‘throws’ is used in method signatures to declare that a method may throw exceptions.
What is a collection in Java?
A collection is an object that can hold multiple values, such as lists, sets, and maps.
What does the ‘ArrayList’ class do?
ArrayList is a resizable array implementation of the List interface.