0% found this document useful (0 votes)
33 views25 pages

CAT-1 Question Bank

The document discusses why Java is platform independent. It explains that Java code is compiled to bytecode, which can run on any Java Virtual Machine (JVM). The JVM then interprets the bytecode to execute the program. While the JVM is platform dependent, the bytecode itself is platform independent. It also discusses the steps in executing a Java program from writing code to bytecode generation to interpretation by the JVM.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views25 pages

CAT-1 Question Bank

The document discusses why Java is platform independent. It explains that Java code is compiled to bytecode, which can run on any Java Virtual Machine (JVM). The JVM then interprets the bytecode to execute the program. While the JVM is platform dependent, the bytecode itself is platform independent. It also discusses the steps in executing a Java program from writing code to bytecode generation to interpretation by the JVM.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

CAT -1 Question bank-SWE 1007

1.Why java is platform independent

Answer:
The meaning of Java platform-independent is that the Java compiled code(byte code)
can run on all operating systems. A program is written in a language that is a human-
readable language. It may contain words, phrases, etc which the machine does not
understand. For the source code to be understood by the machine, it needs to be in a
language understood by machines, typically a machine-level language. So, here
comes the role of a compiler. The compiler converts the high-level language (human
language) into a format understood by the machines.

Therefore, a compiler is a program that translates the source code for another program
from a programming language into executable code. This executable code may be a
sequence of machine instructions that can be executed by the CPU directly, or it may
be an intermediate representation that is interpreted by a virtual machine. This
intermediate representation in Java is the Java Byte Code.

Step-by-Step Execution of Java Program


1.Whenever a program is written in JAVA, the javac compiles it.
2. The result of the JAVA compiler is the .class file or the bytecode and not the
machine’s native code (unlike the C compiler).
3. The bytecode generated is a non-executable code and needs an interpreter to
execute on a machine. This interpreter is the JVM and thus the Bytecode is executed
by the JVM.
4. And finally, the program runs to give the desired output.

In the case of C or C++ (languages that are not platform independent), the compiler
generates a .exe file which is OS dependent. When we try to run this .exe file on
another OS it does not run, since it is OS-dependent and hence is not compatible with
the other OS.

Why Java is platform-independent but JVM is platform dependent?

In Java, the main point here is that the JVM depends on the operating system – so if
you are running Mac OS X you will have a different JVM than if you are running
Windows or some other operating system. This fact can be verified by trying to
download the JVM for your particular machine – when trying to download it, you will
be given a list of JVMs corresponding to different operating systems, and you will
obviously pick whichever JVM is targeted for the operating system that you are
running. So we can conclude that JVM is platform-dependent and it is the reason why
Java is able to become “Platform Independent”.

2. Why java does not support multiple inheritance


Answer :
Multiple Inheritance is a feature of an object-oriented concept, where a class can
inherit properties of more than one parent class. The problem occurs when there exist
methods with the same signature in both the superclasses and subclass. On calling the
method, the compiler cannot determine which class method to be called and even on
calling which class method gets the priority.
Thus, Multiple inheritances lead to ambiguity.
For example, if there is a class named Sub and there are two classes Super1 and
Super2 and if both contains a method named sample().
And if the class sub inherits both classes Super1 and Super2 then there will be two
copies of the sampling method one from each superclass and it is ambiguous to
decide which method to be executed.

Hence, Multiple inheritance is not supported by Java using classes, handling the
complexity that causes due to multiple inheritances is very complex. It creates
problems during various operations like casting, constructor chaining, etc, and the
above all reason is that there are very few scenarios on which we actually need
multiple inheritances, so better to omit it for keeping things simple and
straightforward.
But the same can be handled by using interfaces. A class can implement two or
more interfaces. In case both the implemented interfaces contain default methods
with the same method signature, the implementing class should explicitly specify
which default method is to be used in some method excluding the main() of
implementing class using super keyword, or it should override the default method in
the implementing class, or it should specify which default method is to be used in
the default overridden method of the implementing class.

3. What is the difference between C, C++ and java


(Note: Out of these write any 7 to 8 points)
4. Difference between class, abstract class, interface
5. What is polymorphism, Types of polymorphism (Runtime and compile time
with example)
Polymorphism is one of the most important OOPs concepts. Its is a concept by which
we can perform single task in multiple ways. There are two types of polymorphism
one is Compile-time polymorphism and another is run-time polymorphism.
Method overloading is the example of compile time polymorphism and method
overriding is the example of run-time polymorphism.

Sr. Key Compile-time polymorphism Runtime polymorphism


No.

1 Basic Compile time polymorphism R un time polymorphism where at


means binding is occuring at run time we came to know which
compile time method is going to invoke

2 Static/DynamicBi It can be achieved through It can be achieved through dynamic


nding static binding binding

4. Inheritance Inheritance is not involved Inheritance is involved

5 Example Method overloading is an Method overriding is an example


Sr. Key Compile-time polymorphism Runtime polymorphism
No.

example of compile time of runtime polymorphism


polymorphism

Example of Compile-time Polymorphism


public class Main {
public static void main(String args[]) {
CompileTimePloymorphismExample obj = new
CompileTimePloymorphismExample();
obj.display();
obj.display("Polymorphism");
}
}
class CompileTimePloymorphismExample {
void display() {
System.out.println("In Display without parameter");
}
void display(String value) {
System.out.println("In Display with parameter" + value);
}
}
Example of Runtime Polymorphism
public class Main {
public static void main(String args[]) {
RunTimePolymorphismParentClassExample obj = new
RunTimePolymorphismSubClassExample();
obj.display();
}
}

class RunTimePolymorphismParentClassExample {
public void display() {
System.out.println("Overridden Method");
}
}

public class RunTimePolymorphismSubClassExample extends


RunTimePolymorphismParentExample {

public void display() {


System.out.println("Overriding Method");
}
}

6. Tokens in java programming

Answer:

The Java compiler breaks the line of code into text (words) is called Java tokens.
These are the smallest element of the Java program. The Java compiler identified
these words as tokens. These tokens are separated by the delimiters. It is useful for
compilers to detect errors. Remember that the delimiters are not part of the Java
tokens.

token <= identifier | keyword | separator | operator | literal | comment

(For more explanation on each tokes refer to the PPT - introduction)

7. Datatypes and its features


Answer:

Data Types in Java


Data types specify the different sizes and values that can be stored in the variable.
There are two types of data types in Java:

Primitive data types: The primitive data types include boolean, char, byte, short, int,
long, float and double.
Non-primitive data types: The non-primitive data types include Classes, Interfaces,
and Arrays.

Refer to the URL for the complete answer: https://www.javatpoint.com/java-data-


types

8. Garbage collection in java

Answer: Garbage collection in Java is the process by which Java programs perform
automatic memory management. Java programs compile to bytecode that can be run
on a Java Virtual Machine, or JVM for short. When Java programs run on the JVM,
objects are created on the heap, which is a portion of memory dedicated to the
program. Eventually, some objects will no longer be needed. The garbage collector
finds these unused objects and deletes them to free up memory.

What is Garbage Collection?


In C/C++, a programmer is responsible for both the creation and destruction of
objects. Usually, programmer neglects the destruction of useless objects. Due to this
negligence, at a certain point, sufficient memory may not be available to create new
objects, and the entire program will terminate abnormally, causing
OutOfMemoryErrors.

But in Java, the programmer need not care for all those objects which are no longer in
use. Garbage collector destroys these objects. The main objective of Garbage
Collector is to free heap memory by destroying unreachable objects. The garbage
collector is the best example of the Daemon thread as it is always running in the
background.

How Does Garbage Collection in Java works?


Java garbage collection is an automatic process. Automatic garbage collection is the
process of looking at heap memory, identifying which objects are in use and which
are not, and deleting the unused objects. An in-use object, or a referenced object,
means that some part of your program still maintains a pointer to that object. An
unused or unreferenced object is no longer referenced by any part of your program.
So the memory used by an unreferenced object can be reclaimed. The programmer
does not need to mark objects to be deleted explicitly. The garbage collection
implementation lives in the JVM.

Types of Activities in Java Garbage Collection

Two types of garbage collection activity usually happen in Java. These are:
1. Minor or incremental Garbage Collection: It is said to have occurred when
unreachable objects in the young generation heap memory are removed.
2. Major or Full Garbage Collection: It is said to have occurred when the objects
that survived the minor garbage collection are copied into the old generation or
permanent generation heap memory are removed. When compared to the young
generation, garbage collection happens less frequently in the old generation.

Important Concepts Related to Garbage Collection in Java

1. Unreachable objects: An object is said to be unreachable if it doesn’t contain


any reference to it. Also, note that objects which are part of the island of isolation
are also unreachable.
Integer i = new Integer(4);
// the new Integer object is reachable via the reference in 'i'
i = null;
// the Integer object is no longer reachable.
2. Eligibility for garbage collection: An object is said to be eligible for
GC(garbage collection) if it is unreachable. After i = null, integer object 4 in the
heap area is suitable for garbage collection in the above image.
Ways to make an object eligible for Garbage Collector
 Even though the programmer is not responsible for destroying useless objects
but it is highly recommended to make an object unreachable(thus eligible for
GC) if it is no longer required.
 There are generally four ways to make an object eligible for garbage collection.
1. Nullifying the reference variable
2. Re-assigning the reference variable
3. An object created inside the method
4. Island of Isolation
Ways for requesting JVM to run Garbage Collector
 Once we make an object eligible for garbage collection, it may not destroy
immediately by the garbage collector. Whenever JVM runs the Garbage
Collector program, then only the object will be destroyed. But when JVM runs
Garbage Collector, we can not expect.
 We can also request JVM to run Garbage Collector. There are two ways to do it
:
1. Using System.gc() method: System class contain static method gc() for
requesting JVM to run Garbage Collector.
2. Using Runtime.getRuntime().gc() method: Runtime class allows the
application to interface with the JVM in which the application is running.
Hence by using its gc() method, we can request JVM to run Garbage
Collector.
3. There is no guarantee that any of the above two methods will run Garbage
Collector.
4. The call System.gc() is effectively equivalent to the call
: Runtime.getRuntime().gc()
Finalization
 Just before destroying an object, Garbage Collector calls finalize() method on
the object to perform cleanup activities. Once finalize() method completes,
Garbage Collector destroys that object.
 finalize() method is present in Object class with the following prototype.
protected void finalize() throws Throwable
Based on our requirement, we can override finalize() method for performing our
cleanup activities like closing connection from the database.
1. The finalize() method is called by Garbage Collector, not JVM. However,
Garbage Collector is one of the modules of JVM.
2. Object class finalize() method has an empty implementation. Thus, it is
recommended to override the finalize() method to dispose of system resources or
perform other cleanups.
3. The finalize() method is never invoked more than once for any object.
4. If an uncaught exception is thrown by the finalize() method, the exception is
ignored, and the finalization of that object terminates.
Advantages of Garbage Collection in Java
The advantages of Garbage Collection in Java are:
 It makes java memory-efficient because the garbage collector removes the
unreferenced objects from heap memory.
 It is automatically done by the garbage collector(a part of JVM), so we don’t
need extra effort.

Example:
class garbage
{
public void finalize()
{
System.out.println("object is garbage collected");
}

public static void main(String args[])


{
garbage g1 = new garbage();
garbage g2=new garbage();
garbage g3=new garbage();
g1=null;
g2=null;
g3=null;
System.gc();
System.out.println("SADF");
}
}

9. Explain the keyword this and super


Answer: In java, super keyword is used to access methods of the parent
class while this is used to access methods of the current class.
this keyword is a reserved keyword in java i.e, we can’t use it as an identifier. It is
used to refer current class’s instance as well as static members. It can be used in
various contexts as given below:
 to refer instance variable of current class
 to invoke or initiate current class constructor
 can be passed as an argument in the method call
 can be passed as argument in the constructor call
 can be used to return the current class instance
Example
 Java

// Program to illustrate this keyword

// is used to refer current class

class RR {
// instance variable

int a = 10;

// static variable

static int b = 20;

void GFG()

// referring current class(i.e, class RR)

// instance variable(i.e, a)

this.a = 100;

System.out.println(a);

// referring current class(i.e, class RR)

// static variable(i.e, b)

this.b = 600;

System.out.println(b);

}
public static void main(String[] args)

// Uncomment this and see here you get

// Compile Time Error since cannot use

// 'this' in static context.

// this.a = 700;

new RR().GFG();

Output

100
600

10. Dynamic and static bindinig - difference

There are certain key points that are needed to be remembered before adhering
forward where we will be discussing and implementing static and dynamic bindings
in Java later concluding out the differences.
 private, final and static members (methods and variables) use static binding
while for virtual methods (In Java methods are virtual by default) binding is
done during run time based upon the run time object.
 The static binding uses Type information for binding while Dynamic binding
uses Objects to resolve to bind.
 Overloaded methods are resolved (deciding which method to be called when
there are multiple methods with the same name) using static binding while
overridden methods use dynamic binding, i.e, at run time.

Static Binding
The binding which can be resolved at compile time by the compiler is known as
static or early binding. The binding of all the static, private, and final methods is
done at compile-time.
Example:
 Java

// Java Program to Illustrate Static Binding

// Main class

class NewClass {

// Static nested inner class

// Class 1

public static class superclass {

// Method of inner class

static void print()

// Print statement

System.out.println(

"print() in superclass is called");

}
}

// Static nested inner class

// Class 2

public static class subclass extends superclass {

// Method of inner class

static void print()

// print statement

System.out.println(

"print() in subclass is called");

// Method of main class

// Main driver method

public static void main(String[] args)

{
// Creating objects of static inner classes

// inside main() method

superclass A = new superclass();

superclass B = new subclass();

// Calling method over above objects

A.print();

B.print();

Output
print() in superclass is called
print() in superclass is called
Output Explanation: As you can see, in both cases the print method of the
superclass is called. Let us discuss how this happens
 We have created one object of subclass and one object of the superclass with the
reference of the superclass.
 Since the print method of the superclass is static, the compiler knows that it will
not be overridden in subclasses and hence compiler knows during compile time
which print method to call and hence no ambiguity.
As an exercise, the reader can change the reference of object B to subclass and then
check the output.

Dynamic Binding

In Dynamic binding compiler doesn’t decide the method to be called. Overriding is


a perfect example of dynamic binding. In overriding both parent and child classes
have the same method.
Example:
 Java

// Java Program to Illustrate Dynamic Binding

// Main class

public class GFG {

// Static nested inner class

// Class 1

public static class superclass {

// Method of inner class 1

void print()

// Print statement

System.out.println(

"print in superclass is called");

}
// Static nested inner class

// Class 2

public static class subclass extends superclass {

// Method of inner class 2

@Override void print()

// Print statement

System.out.println(

"print in subclass is called");

// Method inside main class

public static void main(String[] args)

// Creating object of inner class 1

// with reference to constructor of super class


superclass A = new superclass();

// Creating object of inner class 1

// with reference to constructor of sub class

superclass B = new subclass();

// Calling print() method over above objects

A.print();

B.print();

Output
print in superclass is called
print in subclass is called
Output Explanation: Here the output differs. But why? Let’s break down the code
and understand it thoroughly.
 Methods are not static in this code.
 During compilation, the compiler has no idea as to which print has to be called
since the compiler goes only by referencing variable not by the type of object,
and therefore the binding would be delayed to runtime and therefore the
corresponding version of the print will be called based on type on an object

11. Advantages of inner classes or Types of inner classes


Answer :
In Java, inner class refers to the class that is declared inside class or interface
which were mainly introduced, to sum up, same logically relatable classes as Java
is purely object-oriented so bringing it closer to the real world. Now geeks you
must be wondering why they were introduced?

There are certain advantages associated with inner classes are as follows:
 Making code clean and readable.
 Private methods of the outer class can be accessed, so bringing a new
dimension and making it closer to the real world.
 Optimizing the code module.

Types of Inner Classes

Types of Inner Classes

Inner classes are classified into four types: static, non-static, local and anonymous.

Static Inner Classes

These are the simplest type of inner classes. Static inner classes are those that are
declared inside a class and marked static. It should be noted that these classes can
only be accessed using an instance of the outer class. You can take advantage of static
nested classes for grouping related classes together.

Non-static Inner Classes

A non-static inner class as the name suggests, is associated with an instance of an


outer class. All the members (variables and methods) of the outer class are accessible
from these classes.

Local Inner Classes

Local inner classes are defined within a method. They have access to all the members
(variables and methods) of the enclosing class but they cannot be instantiated from
outside the method in which they are defined. An inner class defined locally may only
be instantiated inside its method where it has been defined.

A method local inner class is accessible only within the method in which it was
defined, and cannot be referenced by any other code outside the method in which it is
defined. A method local inner class can access local variables from the enclosing
scope (including final variables).
Anonymous Inner Classes

Inner classes that don’t have names are also known as anonymous inner classes. Both
the declaration and instantiation of an anonymous inner class occur simultaneously.
Anonymous inner classes cannot have explicit constructors, just like all local inner
classes. Anonymous inner classes are useful when you have to use a local inner class
only once.

For example refer to the PPT

12. Features of Java programming


Simple
Java is very easy to learn, and its syntax is simple, clean and easy to understand.
According to Sun Microsystem, Java language is a simple programming language
because:
(i) Java syntax is based on C++ (so easier for programmers to learn it after C++).
(ii) Java has removed many complicated and rarely-used features, for example,
explicit pointers, operator overloading, etc.

Secured
Java is best known for its security. With Java, we can develop virus-free systems.
Java is secured because:
No explicit pointer

Java Programs run inside a virtual machine sandbox


how Java is secured
Classloader: Classloader in Java is a part of the Java Runtime Environment (JRE)
which is used to load Java classes into the Java Virtual Machine dynamically. It adds
security by separating the package for the classes of the local file system from those
that are imported from network sources.
Bytecode Verifier: It checks the code fragments for illegal code that can violate
access rights to objects.
Security Manager: It determines what resources a class can access such as reading and
writing to the local disk.
Java language provides these securities by default. Some security can also be
provided by an application developer explicitly through SSL, JAAS, Cryptography,
etc.

Robust
The English mining of Robust is strong. Java is robust because:

It uses strong memory management.


There is a lack of pointers that avoids security problems.
Java provides automatic garbage collection which runs on the Java Virtual Machine to
get rid of objects which are not being used by a Java application anymore.
There are exception handling and the type checking mechanism in Java. All these
points make Java robust.
Architecture-neutral
Java is architecture neutral because there are no implementation dependent features,
for example, the size of primitive types is fixed.

In C programming, int data type occupies 2 bytes of memory for 32-bit architecture
and 4 bytes of memory for 64-bit architecture. However, it occupies 4 bytes of
memory for both 32 and 64-bit architectures in Java.

Portable
Java is portable because it facilitates you to carry the Java bytecode to any platform. It
doesn't require any implementation.

High-performance
Java is faster than other traditional interpreted programming languages because Java
bytecode is "close" to native code. It is still a little bit slower than a compiled
language (e.g., C++). Java is an interpreted language that is why it is slower than
compiled languages, e.g., C, C++, etc.

Distributed
Java is distributed because it facilitates users to create distributed applications in Java.
RMI and EJB are used for creating distributed applications. This feature of Java
makes us able to access files by calling the methods from any machine on the internet.

Multi-threaded
A thread is like a separate program, executing concurrently. We can write Java
programs that deal with many tasks at once by defining multiple threads. The main
advantage of multi-threading is that it doesn't occupy memory for each thread. It
shares a common memory area. Threads are important for multi-media, Web
applications, etc.

Dynamic
Java is a dynamic language. It supports the dynamic loading of classes. It means
classes are loaded on demand. It also supports functions from its native languages,
i.e., C and C++.

Java supports dynamic compilation and automatic memory management (garbage


collection).

13. How java improves the data security


Answer:

Java is the most popular object-oriented programming language. It provides a variety of salient
features that are preferred by the developers. It is the reason that a billion of devices runs on Java.
In this section, we are going to discuss why Java is secure.

Java is secure due to the following reasons:

 Java programs run inside a virtual machine which is known as a sandbox.


 Java does not support explicit pointer.
 Byte-code verifier checks the code fragments for illegal code that can violate
access right to object.
 It provides java.security package implements explicit security.
 It provides library level safety.
 Run-time security check takes place when we load new code.

Java provides some other features that make Java more secure.

[1] JVM
[2] Security API's
[3] Security Manager
[4] Auto Memory Management
[5] No Concept of Pointers
[6] Compile-time Checking
[7] Cryptographic Security
[8] Java Sandbox
[9] Exception Handling
[10] ClassLoader
JVM

JVM plays a vital role to provide security. It verifies the byte-code. The JVM
provides guarantees that there is no unsafe operation going to execute. It also helps to
diminish the possibilities of the programmers who suffer from memory safety flaws.

Security API's

Java class libraries provide several API that leads to security. These APIs contain
cryptographic algorithms and authentication protocols that lead to secure
communication.

Byte Code

Every time when a user compiles the Java program, the Java compiler creates a class
file with Bytecode, which are tested by the JVM at the time of program execution for
viruses and other malicious files.

Security Manager

The security manager is responsible for checking the permissions and properties of
the classes. It monitors the system resources accessed by the authorized classes. It
also controls socket connections.

No Concept of Pointers

Java does not provide support for pointers concept. It is the main security features of
Java. The use of pointers may lead to unauthorized read or write operations.
Therefore, the user cannot point to any memory locations.

Memory management
Java automatically manages memory which is known as garbage collection. The JVM
manages memory itself. The programmers are free from memory management.
Hence, there is no chance to fault in memory management.

Compile-time checking

Compile-time checking also makes the Java secure. Consider a scenario in which an
unauthorized method is trying to access the private variable, in this case, the JVM
gives the compile-time error. It prevents the system from the crash.

Cryptographic Security

Java provides a class named java.secrurity.SourceCode that also provides security. If


we get code from other sources, we should check from where the code is coming. The
class maintains the source information and provides guarantees to keep a digital
signature and cryptographic security.

Java Sandbox

Java Sandbox is a major component of security consideration. It is a restricted area


where applets are run. Java does not provide system resources without check if an
applet is to be run.

Exception Handling

The exception handling feature adds more security in Java. The feature reports the
error to the programmer during the runtime. The code will not run until the
programmer will not rectify it.

Java ClassLoader

There are a number of class loaders present in JVM. It provides and maintains
namespaces for specific classes. The advantage of the ClassLoader is that the
untrusted classes would not behave like a trusted one.

14. Explain the working of JVM


Answer:
JVM(Java Virtual Machine) acts as a run-time engine to run Java applications. JVM is the
one that actually calls the main method present in a java code. JVM is a part of JRE(Java
Runtime Environment).
Java applications are called WORA (Write Once Run Anywhere). This means a
programmer can develop Java code on one system and can expect it to run on any other
Java-enabled system without any adjustment. This is all possible because of JVM.
When we compile a .java file, .class files(contains byte-code) with the same class names
present in .java file are generated by the Java compiler. This .class file goes into various
steps when we run it. These steps together describe the whole JVM.
Class Loader Subsystem
It is mainly responsible for three activities.
 Loading
 Linking
 Initialization
Loading: The Class loader reads the “.class” file, generate the corresponding binary data
and save it in the method area. For each “.class” file, JVM stores the following information
in the method area.

 The fully qualified name of the loaded class and its immediate parent class.
 Whether the “.class” file is related to Class or Interface or Enum.
 Modifier, Variables and Method information etc.
After loading the “.class” file, JVM creates an object of type Class to represent this file in
the heap memory. Please note that this object is of type Class predefined
in java.lang package. These Class object can be used by the programmer for getting class
level information like the name of the class, parent name, methods and variable information
etc. To get this object reference we can use getClass() method of Object class.
Linking: Performs verification, preparation, and (optionally) resolution.

 Verification: It ensures the correctness of the .class file i.e. it checks whether this file is
properly formatted and generated by a valid compiler or not. If verification fails, we get
run-time exception java.lang.VerifyError. This activity is done by the component
ByteCodeVerifier. Once this activity is completed then the class file is ready for
compilation.
 Preparation: JVM allocates memory for class static variables and initializing the
memory to default values.
 Resolution: It is the process of replacing symbolic references from the type with direct
references. It is done by searching into the method area to locate the referenced entity.
Initialization: In this phase, all static variables are assigned with their values defined in the
code and static block(if any). This is executed from top to bottom in a class and from parent
to child in the class hierarchy.
In general, there are three class loaders :

 Bootstrap class loader: Every JVM implementation must have a bootstrap class loader,
capable of loading trusted classes. It loads core java API classes present in the
“JAVA_HOME/jre/lib” directory. This path is popularly known as the bootstrap path. It
is implemented in native languages like C, C++.
 Extension class loader: It is a child of the bootstrap class loader. It loads the classes
present in the extensions directories “JAVA_HOME/jre/lib/ext”(Extension path) or any
other directory specified by the java.ext.dirs system property. It is implemented in java
by the sun.misc.Launcher$ExtClassLoader class.
 System/Application class loader: It is a child of the extension class loader. It is
responsible to load classes from the application classpath. It internally uses Environment
Variable which mapped to java.class.path. It is also implemented in Java by
the sun.misc.Launcher$AppClassLoader class.

Expected questions as programs

1. program using method overloading and overriding


2. Program using classes and objects
3. Program using Arrays (possibly 2D array)
4. Program using inheritance (may be multilevel)
5. Program using constructor
6. Program using abstraction, interface.

You might also like