Professional Documents
Culture Documents
Demo
Demo
Date: 21-Oct-2022
1) What is the difference between compiler and interpreter? Which one is better?
Explain.
Compiler Interpreter
Translate the whole source code Translate the whole source code line
at once. by line.
Compiler shows all errors at once, Interpreter runs the code line by line,
making it harder to debug. it displays the error when it gets it,
which makes it easier to debug.
AYUSH DIGGIWAL
Compilers and interpreters both are used to convert a program written in a high-
level language into machine code understood by computers. Compilers usually take
a large amount of time to analyze the source code. However, the overall execution
time is comparatively faster than interpreters. On the other hand, Interpreters
usually take less amount of time to analyze the source code. In case of using
compilers, the program codes are translated into machine code already and hence
the time to execute the code is very less. That’s why Compiler is better than
Interpreter.
AYUSH DIGGIWAL
Characters There is only one primitive data type that deals with individual
characters – the char. The char can hold the value of one character and is
based on 16-bit Unicode encoding. The character might be a letter, digit,
punctuation, a symbol or a control character (e.g., a character value that
represents a newline or a tab).
Final Keyword :
In Java, the final keyword can be used while declaring an entity. Using
the final keyword means that the value can’t be modified in the future. If a
variable is declared with the final keyword, its value cannot be changed once
initialized. Note that the variable does not necessarily have to be initialized at
the time of declaration. If it’s declared but not yet initialized, it’s called a
blank final variable.
AYUSH DIGGIWAL
Abstract:
Java abstract keyword is used to declare an abstract class. An abstract
class can provide the implementation of the interface. It can have abstract
and non-abstract methods. An abstract method can only be used in an
abstract class, and it does not have a body.
Super:
The super keyword is used to call the super or parent class or objects.
Java super keyword is a reference variable that is used to refer to parent class
objects. It can be used to invoke the immediate parent class method.
Break :
Java break keyword is used to break the loop or switch statement. It
breaks the current flow of the program at specified conditions.
Continue:
Java continue keyword is used to continue the loop. It continues the
current flow of the program and skips the remaining code at the specified
condition.
try:
Java try keyword is used to start a block of code that will be tested for
exceptions. The try block must be followed by either catch or finally block.
catch:
The catch block is used to handle the uncertain condition of a try
block. A try block is always followed by a catch block, which handles the
exception that occurs in the associated try block.
throws:
The throws keyword is used for exception handling without try &
catch block. It specifies the exceptions that a method can throw to the caller
and does not handle itself.
Package:
A java package is a group of similar types of classes, interfaces and
sub-packages. Package in java can be categorized in two form, built-in
package and user-defined package. There are many built-in packages such as
java, lang, awt, javax etc.
AYUSH DIGGIWAL
4) What do you mean by JVM?
A Java virtual machine is a virtual machine that enables a computer to run Java
programs as well as programs written in other languages that are also compiled to
Java byte code. The JVM is detailed by a specification that formally describes what is
required in a JVM implementation. Java Virtual Machine is an abstract machine. It is
a specification that provides runtime environment in which java byte code can be
executed. JVMs are available for many hardware and software platforms i.e. JVM is
platform dependent.
It is:
A specification where working of Java Virtual Machine is specified. But
implementation provider is independent to choose the algorithm. Its
implementation has been provided by Oracle and other companies.
An implementation its implementation is known as JRE (Java Runtime
Environment).
Runtime Instance Whenever you write java command on the command
prompt to run the java class, an instance of JVM is created.
Loads code
Verifies code
Executes code
Provides runtime environment
Memory area
Class file format
Register set
Garbage-collected heap
Fatal error reporting etc.
AYUSH DIGGIWAL