Is the methodology of hiding the implementation details from the user and only providing the functionality to the users
Back
Why Java is platform independent?
Front
means once compiled you can execute the program on any platform(OS)
The compiler converts the source code to bytecode, which is intermidiate Language, Bytcode can be executed on any platform using JVM
Back
Polymorphism
Front
The ability of a variable, function or object to take multiple forms
Back
Methods
Front
Used to represent the behavior of the object
Must have a return type
Needs to invoked explicitly
No default method is provided by the compiler
Method name may or may not be same as class name
Back
Java
Front
Java is a programming language and computing platform first released by Sun Microsustems in 1995
Back
Why pointers are not used in Java?
Front
Java doesnt use pointers because they are unsafe and increases the complexity of the program
Back
What is OOP?
Front
Object Oriented Programming, OOP is a powerful way to approach the job of programming, and is the center of Java programming.
Back
Object (Java)
Front
An object is a real-world entity that has a state and behavior. An object has three characteristics
State, Behavior and Identity
is created using the 'new' key-word
Back
JRE
Front
(Java Runtime Environment) creates the JVM and ensures dependencies are available to your programs
Back
difference between stack memory and java heap
Front
1)Heap memory is used by all the parts of the application whereas stack memory is used only by one thread of execution
2) Whenever an object is created, its always stored in the heap space and stack memory contains the reference to it, stack memory only contais local primitive variables and reference variables to objects in heap space
3) Objects stored in the heap are globally accessible whereas stack memory cant't be accessed by other threads
4)memory management in stack is done in LIFO manner whereas its more complex in Heap memory because its used globally. Heap memory is divided into Young-Generation, Old-Generation.
5)Stack memory is short-lived whereas heap memory lives from the start till the end of the application execution
6)When stack memory is full java runtime throws java.lang.StackOverFlowError whereas if heap memory is full, it throws java.lang.OutOfMemoryError: Java Heap Space error
7)Stack memory size is very less when compared to Heap memory.
Back
Java Heap
Front
is used by java runtime to allocate memory to Objects and JRE classes
Whenever we create any object, its always created in the heap space
Back
Public access Modifier
Front
Access is not restricted.
Back
protected access modifier
Front
Can not be used for classes and interfaces, it also cannot be used for fields and methods with in interface. Fields, methods and constructors declared protected in a superclass ca be accessed only by superclasses in other packages. Classes in the same package can also access protected fields methods and constructors as well, even if thy are not a subclass of the protected members class
Back
Eager Initialization
Front
The instance of Singleton Class is created at the time of class loading by making the constructor as private you are not allowing other class to create a new instance of the class you want to create the singleton. Instead you are creating one public static method(commonly name as for getInstance()) to provide the single entry point to create the new instance of the class.(this instance is created even though client application migh not be using it.
Back
wrapper class
Front
A class that contains a primitive type value, such as Integer.
Back
Java Platforms / Editions
Front
Java SE (Java Standard Edition), Java EE (Java Enterprise Edition), Java ME (Java Micro Edition), JavaFX
Back
non-static method
Front
No need to use the static keyword before the method name
It is can be called like any general method
It can access any static method and any static variable without creating an instance of the class
Back
Static methods
Front
Must be used before the method name
It is called using the class
they can not access any non-static instance variables or methods
Back
Abstraction vs Encapsulation
Front
1)Abstraction hides details at the design level and Encapsulation hide details at the implementation level
2)Abstraction is used for hiding the unwanted data and giving relevant data, Encapsulation means hiding the code and data into a single unit to protect the data from outside world
3)Abstraction lets you focus on what the objects does instead of how it does it and Encapsulation means hiding the internal details or mechanics of how an object does something.
Back
JVM
Front
(Java Virtual Machine) is the platform component that executes your programs
Back
What is the difference between a local variable and an instance variable?
Front
Local variable is tipically used inside a method constructor or block and has only local scope.
Isntance variable is java is a variable which is bounded to its object itself. these variable are declared within a class. but outside a method. Every object of that class will create its own copy of the variable while using it.
Back
What is a Map in Java
Front
Map is an Interface of Util package which maps unique keys to values. The map interface is not a subset of the main Collection interface andthus it behaves little different from the other collection types.
Map doesnt contain duplicate keys
Each key can map at max one value
Back
Why java is not 100% Object-oriented?
Front
Java is not 100% Object-oriented because it makes use of eight primitive datatypes such as boolean, byte, char, int, float, double, long, short which are not objects.
Back
What is a singleton class in java
Front
Is a class that can have only one object(an instance of the class) at a time limiting the number of objects to only one.
Back
default access modifier
Front
Java provides a default specifier wich is used when no access modifier is present. Any class, field, method or constructor that has no declared access modifier is accessible only by classes in the same package. Is not used for fields and methods within an interface
Back
What is final keyword?
Front
final keyword is used with Class to make sure no other class can extend it, for example String class is final and we can't extend it.
We can use final keyword with methods to make sure child classes can't override it.
final keyword can be used with variables to make sure that it can be assigned only once. However the state of the variable can be changed, for example we can assign a final variable to an object only once but the object variables can change later on.
Java interface variables are by default final and static.
Back
Main Method
Front
public static void main(String[] args)
Every program need a place to start the execution.
public - access modifier meaning global visibility
static - the method can be accessed straight from the class, we dont have to instantiate an object to have a reference and use it
void - means that this method doesnt return a value
main - the name of the method, that is the identifier JVM looks for when executiong Java program
the parameters args is an array of Strigns
Back
What are the main concepts of OOPs in Java?
Front
Inheritance, Encapsulation, Abstraction and Polymorphism
Back
Constructor
Front
Used to initialize the state of an object
Do not have any return type
Is invoke implicitly
A defaul constructor is provided by the compiler if the class has none
Constructor name must always be the same as the class name
Back
how can we make a singleton class
Front
Using eager Initialization or lazy initialization
Back
Java Stack Memory
Front
is used for execution of a thread. They contain method specific values that are short-lived and references to other objects in the heap that are getting referred from the method
Back
Type of Access Modifiers
Front
Default, Private, Protected, Public
Back
What is Java String Pool?
Front
Refers to a collection of Strings which are stored in the heap memory.
Back
Lazy Initialization
Front
Opposite to Eager initialization, here you are going to initialize new instance of the class in getInsstance() method it self. this method will check if there is any instance of that class is already created?
Back
Overloading
Front
is a feature that allows a class to have more than one method having the same name if their arguments list are different.
Back
what are constructors in java
Front
In Java, constructor refers to a block of code which is used to initialize an object. It must have the same name as that of the class. Also, it has no return type and it is automatically called when an object is created.
Back
JDK
Front
(Java Development Kit) allowa you to create Java programs that can be executed and run by the JVM and JRE
Back
Private Access Modifier
Front
fields or methods cannot be used for classes and onterfaces. it also cannot be used for fields and methods within an interface. Fields methods or constructor declared private are strictly controlled, which means they cannot be access bt anywhere outside the enclosing class. A standar design strategy is to make all fields private and provide public getter methods for them.
Back
Super()
Front
represents the current instance of a parent/base class
Used to call the default constructor of the parent/base class
Used to access methods of the base class
Used for pointing the superclass instance
Must be the first line of a block
Back
What is a package in Java?
Front
It is collection of classes with a related purpose.
Back
What are access modifiers in Java?
Front
Are special keywords which are used to restrict the access of a class, constructor, data member and method in another class
Back
This()
Front
represent the current instance of a class
Used to call the default constructor of the same class
Used to access methods of the current class
Used for pointing thecurrent class instance
Must be the first line of a block
Back
Encapsulation
Front
Keeping details (like data and procedures) together in one part of a program so that programmers working on other parts of the program don't need to know about them.
Back
Class
Front
Is a bluePrint that contains fields and methods that describe the behavior of an object
Back
Inheritance
Front
The process where one class acquires the properties of another
Back
Difference between equal() and ==
Front
One is the method and the other is operator
We can use == operators for reference comparison(address comparison) and .equals() method for content comparison
Back
Overriding
Front
Declaring a method in sub class which is already present in parent class is know as method overriding. Overriding is done so that a child class can give its own implementation to a method which is already provided by the parent class.
Back
What is Collection Class in Java
Front
Is a framework that acts as an architecture for storing and manipulating a group of objects. Using Collections you can perform varius tasks like searching, sorting, insertion, manipulation, deletion
Back
What is JIT compiler in Java?
Front
Java-In-Time compiler is a program that helps in converting the java bytecode into instructions that are sent directly to the processor.
Back
ArrayList vs Vector
Front
1)ArrayList is not synchronized, Vector is synchronized
2)ArrayList increments 50% of current array size if the number of elements exceeds from its capacity and vector 100%
3)ArrayList is not a legacy class. Its introduced in JDK and vector is a legacy class
4)ArrayList is fast because it is non-synchronized and vector is opositive
5)ArrayList uses the Iterator interface to traverse the elements and Vector can use the iterator interface or Enumeration interface to traverse the elements