1.WHAT IS JAVA?
Java is a very simple, high level, Secured, Multithreaded, Platform independent, Object
Oriented Programing Language.
It was invented by "Gems Gosling" in SUN MICROSYSTEM for developing internet
applications.
==========================================================
2.WHY JAVA IS VERY SIMPLE?
its syntaxes are similar to c/c++.
it omits many of the features that makes c and c++ complex, confusing and unsafe.
java has inbuilt rich set of programs (API) sothat project development fast and easy.
Note: In java we don't implement most horrible topics such as pointers, structures, union,
operator overloading, multiple classes inheritance and many more.
==========================================================
3.IS JAVA SUPPORTS POINTERS?
Java doesn't supports pointer but internally pointers are there in java software [JVM].
Java native language is C that means java language is developed using C language so Java
software can have pointers internally.
==========================================================
4.WHERE JAVA IS USED?
* Desktop applications such as media player, antivirus and etc...
* Web applications such as Facebook.com, redbus.com and etc...
* Enterprise applications such as banking applications
* Mobile
* Embedded System
* Smartcard
* Robotics
* Games and etc...
==========================================================
5. WHEN SHOULD WE USE C AND WHEN SHOULD WE USE JAVA?
* we use C for developing system level and application level software's which are
stand-alone such as drivers, MS-office and etc...
* we use java only for developing application software(business applications) for
executing in different operating systems either as stand-alone or via network.
==========================================================
6. JAVA FEATURES
01. Simple 06. Object Oriented
02. Secure 07. Multithreaded
03. Robust 08. High Performance
04. Portable 09. Distributed
05. Architecture Natural 10. Dynamic
11. Byte codded
12. Interpreted
13. Garbage Collected
==========================================================
01. SIMPLE
------------
According to Sun, Java language is simple because:
syntax is based on C++ (so easier for programmers to learn it after C++).
removed many confusing and/or rarely-used features e.g., explicit pointers, operator
overloading etc.
No need to remove unreferenced objects because there is Automatic Garbage Collection in
java.
02. SICURE
-------------
Java is secured because:
No explicit pointer
Programs run inside virtual machine sandbox.
Class loader- adds security by separating the package for the classes of the local file system
from those that are imported from network sources.
Bytecode Verifier- checks the code fragments for illegal code that can violate access right to
objects.
Security Manager- determines what resources a class can access such as reading and writing
to the local disk.
These security are provided by java language. Some security can also be provided by
application developer through SSL, JAAS, cryptography etc.
03. ROBUST
-------------
Robust simply means strong. Java uses strong memory management. There are lack of pointers
that avoids security problem. There is automatic garbage collection in java. There is exception
handling and type checking mechanism in java. All these points makes java robust.
04. PORTABLE
----------------
We may carry the java bytecode to any platform.
05. ARCHITECTURAL NATURAL
---------------------------------------
There is no implementation dependent features e.g. size of primitive types is set.
06. OBJECT ORIENTED
-----------------------------
Object-oriented means we organize our software as a combination of different types of objects
that incorporates both data and behavior.
Object-oriented programming(OOPs) is a methodology that simplify software development
and maintenance by providing some rules.
Basic concepts of OOPs are:
Object
Class
Inheritance
Polymorphism
Abstraction
Encapsulation
07. MULTITHREADED
---------------------------
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 shares the same memory. Threads are important for multi-media,
Web applications etc.
08. HIGH PERFORMANCE
--------------------------------
Java is faster than traditional interpretation since byte code is "close" to native code still
somewhat slower than a compiled language (e.g., C++)
09. DISTRIBUTED
----------------------
We can create distributed applications in java. RMI and EJB are used for creating distributed
applications. We may access files by calling the methods from any machine on the internet.
10. DYNAMIC
-----------------
==========================================================
07. WHAT IS PLATFORM, PLATFORM DEPANDENCY & PLATFORM INDEPENDENCY?
PLATFORM
---------------
A platform is basically the hardware or software environment in which programs are loaded and runs
There are two types of platforms software-based and hardware-based. Java provides software-based
platform.
PLATFORM DEPENDENCY & INDEPENDENCY
--------------------------------------------------------------
When you develop a program in operating system if it is not executed in different os than
it is called Platform dependent,
if it is executed it is called Platform independent.
==========================================================
08.WHAT IS THE MEANING OF
1. SOURCE CODE
Developer written program, it is written according to the programming language syntax.
2.COMPILED CODE
Compiler generated program that is converted from source code.
3.EXECUTABLE CODE
Operating System understandable readily executable program.(.exe)
4. COMPILATION
It is a process of translating source code into compiled code.
5. EXECUTION
It is process of running compiled code to get output.
6. INTERPRETER
It is also translation program that converts source code into machine language but line by line.
7. COMPILER
It is a translation program that converts source code into machine language at once.
==========================================================
09. WHY C, C++ PROGRAMING LANGUAGES ARE PLATFORM DEPENDENT?
Because C, C++ program compiled code contains machine language of current operating
system whose format is not understandable to other operating system.
==========================================================
10. HOW JAVA ACHIEVED PLATEFORM INDEPENDENCY?
Java achieved platform independency by moving machine language generation from compilation
phase to execution phase by introducing "Byte code" and "JVM".
Byte Code is an intermediate language for all operating system it is native language for JVM.
JVM is a java platform, it runs java byte code by translating it into current operating system
machine languages.
==========================================================
11. WHY JVM PLATFORM DEPENDENT?
JVM is platform dependent because it takes java bytecodes and generates os dependent
machine language.
so java software is platform dependent, since JVM platform dependent.
we must have different java software for every operating system separately.
==========================================================
12. EXPLAIN WHY JAVA IS CALLED LANGUAGE, PLATFORM & TECHNOLOGY?
*JAVA is programming language because it is providing syntax and semantics for developing
new application.
*JAVA is a platform because it is providing its own runtime environment for executing java
programs that is JVM.
*JAVA is a technology because it is providing rich set of predefine programs for developing
project fast and easy.
==========================================================
JAVA SOFTWARE INTERVIEW QUESTION
-------------------------------------------------------
01. HOW MANY TYPE OF JAVA SOFTWARES DO WE HAVE?
JAVA software is divided into two parts
1. jdk (java development kit)
2. jre (java runtime environment)
note: jdk and jre are called principle products of java software.
==========================================================
02. WHAT IS THE DIFFERENCE BETWEEN JDK, JRE AND JIT?
JVM is a subset of JRE and JRE is the subset of JDK. When we install JDK, JRE also installed
automatically. JRE software is available as a separate pack, so we can install JRE alone.
JDK has both compiler and JVM. so using JDK we can develop, compile and execute new
java applications and also we can modify, compile and execute already developed applications.
JRE has only JVM hence using JRE we can only execute already developed applications.
==========================================================
03. WHAT IS THE MEANING OF MAJOR AND MINOR VERSION OF JAVA?
jdk 1.7.0 --------------------> major version
jdk1.7.0_01 |
jdk1.7.0_02 |
jdk1.7.0_03 |------> minor version
jdk1.7.0_04 |
jdk1.7.0_05 |
jdk1.7.0_06 |
==========================================================
04. WHY JAVA IS CALLED OPEN SOURCE SOFTWARE?
JAVA is open source because its source code comes with jdk installation.
==========================================================
ENVIRONMENT VARIABLES INTERVIEW QUESTIONS
------------------------------------------------------------------------
01. WHAT IS THE ENVIRONMENT VARIABLE?
The variable created in operating system to store software's binary and library files are called
environment variable.
==================================================================
02. WHAT IS THE DIFFERENCE BETWEEN BINARY FILES AND LIBRARY FILES?
Binary Files- are command files by default stored in a folder called "bin".
Library Files- are program files by default stored in a folder called "lib".
==================================================================
03. WHAT IS THE DIFFERENCE BETWEEN PATH, CLASSPATH AND JAVA_HOME?
Path is a mediator between developer and operating system to inform software binary files path.
Class Path is a mediator between developer and compiler , JVM to inform the library files
path those are used in our source code.
JAVA_HOME -the Java software installed directory is called JAVA_HOME.
==================================================================
04.WHY "PATH" IS USED BY OS AND WHY CLASS PATH IS USED BY COMPILER AND JVM?
Path is used for locating a software's binary files. PATH is used by OS for finding the binary files.
Class path is used for identifying library file of a software. It is used by compiler and JVM for identifying
java classes path.
==================================================================
05. WHO WILL USE JAVA_HOME?
JAVA_HOME used for locating JVM software installed directory. It is used by programmer
or a server software like tomcat for identifying java software installed directory.
==========================================================
JAVA PROGRAMMING INTERVIEW QUESTIONS
---------------------------------------------------------------
01. WHAT ARE THE 10 PROGRAMMING ELEMENTS OF JAVA LANGUAGE?
1. package
2. class
3. interface
4. abstract
5. enum
6. annotation
7. variables
8. method
PACKAGE is a folder that is linked with .class . It is used for grouping related classes and
interfaces also used for separating new classes from existing class if both have same name.
CLASS is a top level block which is used for grouping variables and methods.
CLASS is a blue print of an object that represents group of objects of same type.
it is called blue print becoz it represent many object of same type.
OBJECT is a real-world thing which is an instance of a class in java.
INSTANCE - Object is an instance of an class means for storing object data some
memory is allocated from the class this memory is called instance.
==========================================================
OBJECT ORIENTED PROGRAMMIN
--------------------------------------------------
01. WHAT IS OOP WHY OOP?
OOP is a methodology. It provides suggestion for implementing real-world object in programming
world.
OOP concepts are given for implementing real world object in programming world for automatic
real-world business operation by achieving security and dynamic method dispatching.
* For representing real world OOP has a concept called class.
* For achieving security OOP has a concept is encapsulation.
* For achieving DMD OOP has concept abstraction, inheritance, polymorphism.
=>Representing an object mean creating a class with this object name, with variable and method for
storing value of this object and for implementing its operation.
=>Achieving security means not allowed me other programmer to access object data directly,
allow me other programmer access object data with an proper validation and authentication.
=>Achieve DMD means calling a method and executing it dynamically from different subclass
of subtype based on subclass is passed.
Example for DMD:
----------------------
We have one ATM machine we can withdraw money from this ATM machine from or
using any Bank ATM Card this phenomena is called DMD.
Advantage of DMD
------------------------
We can develop single user class for achieving services from different subclass of
same type of an object.
=============================================================================
02. INSTEAD DEVELOPPING OOP CONCEPT IN STRUCTURE ORIENTED PROGRAMMING
LANGUAGES WHY SAPERATE LANGUAGES ARE INVENTED?
In OOP concept programming style is class based, structure programming function based
if we want to implement OOP Concept in structure program we must rebuilt previously
developed applications.
==================================================================
03. WHAT IS OOP PRINCIPLE?
OOP principles are suggestions, they provide a way to implement an object by achieving
security to data, Reusability in functionality, Achieving runtime polymorphism(DMD).
we have 3 OOP Principles
1. Encapsulation
2. Inheritance
3. Polymorphism
We also have another principle called Abstraction. It is object modeling principle.
By following Abstraction we will declare object, than by following Encapsulation,
Inheritance, Polymorphism we will implement those operations by achieving SRR-
security reusability runtime polymorphism.
===================================================================
04. WHAT IS ENCAPSULATION?
Encapsulation is the process of creating a class with variables and methods as a single group
or unit, providing access to these variables or data by a these methods with a proper validation
and calculation is called encapsulation.
"protecting object data from direct accessing by user."
==================================================================
05. WHAT IS INHERITANCE?
Inheritance is the process of creating a new class driving from an existing class for obtaining
properties and behaviors of an object to this new object to treat it as an existing object.
==================================================================
06. WHAT IS POLYMORPHISM?
Polymorphism means having multiple forms, so by following polymorphism we are defining
multiple methods with same name either with same implementation or different implementation.
"providing multiple implementation to the same method."
===================================================================
07. WHAT IS ABSTARTION?
Abstraction is a process of creating a class "by hiding implementation details of a method
operations, providing only necessary information for accessing this method operation."
"hiding implementation details of a method from user programmer."
==================================================================
08. WHAT IS THE ADVANTAGES OF INHERITANCE?
1. Obtaining type.
2. Code reusability.
3. Overriding.
4. Extending.
5. Implementing.
6. Loose coupling and Runtime Polymorphism.
==================================================================
09. HOW CAN WE DEVELOP INHERITANCE IN JAVA?
We can develop inheritance in Java using
1. extends
2. implements keywords
extends
--------
* It is used to provide reusability to subclass for accessing and executing methods given in
subclass.
* It is allowed between two classes or two interfaces for developing inheritance.
implements
--------------
* It provides forcibility to subclass for implementing logic to the methods given in subclass.
* It can be used only for driving subclass from super interface.
===================================================================
10. WHEN SHOULD WE DEVELOP INHERITANCE?
When we find multiple object of same type having same property and behaviors with different
implementation. We must develop these object classes with inheritance.
==================================================================
METHOD HIDING & OVERRIDING
---------------------------------------------
01. WHAT IS THE MEANING OF METHOD HIDING?
Redefining super class static method in subclass with same prototype is called "method hiding".
==================================================================
02. WHAT IS THE MEANING OF METHOD OVERRIDING?
Redefining super class Non-static method in subclass with same prototype is called "method
overriding".
==================================================================
03. WHEN SHOULD WE OVERRIDE SUPER CLASS METHOD IN SUBCLASS?
If the super class method logic is not fulfilling subclass business requirements, sub class should
override that method with required business logic. Usually in super class, methods are defined with generic logic which is common for all subclasses.
the best example is toString() method.
==================================================================
04. IN SUBCLASS WHEN A METHOD IS CONSIDERED AS OVERRIDING METHOD?
If a method in sub class contains signature same as super class non private method, sub class
method is treated as overriding method and super class method is treated as overridden
method.
==================================================================
05. WHAT ARE THE 4 RULES WE MUST FOLLOW IN METHOD OVERRIDING?
Rules are:
1. RETURN TYPE should be same as super class method.
2. STATIC MODIFIER should not be removed or added.
3. ACCESSIBILITY MODIFIER should be same as super class method or it can be increased
but should not be decreased.
private, default, protected, public.
FOCUS:
----------
We can not override private method because it is not inherited to subclass.If we override
it in subclass no CE and it is not considered ass overriding method, it is just considered
as subclass own method. so this method can have its own return type NAM and AM.
4.THROWS CLOUSE should not be added with checked exception if super class does not
contains it. If super class method contain throws clouse, subclass overriding method should
contain throws clouse with same exception class or its sub class or it can be removed.
==================================================================
05.WHAT IS CO-VARIANT RETURN METHOD?
Now, since java5, it is possible to override any method by changing the return type if the return type of the subclass overriding method is subclass type. It is known as covariant return type.
==========================================================
METHOD OVERLOADING
-----------------------------------
01. WHAT IS METHOD OVERLOADING?
Difining multiple methods with the same name but different parameter type/list/order is called
method overloading.
==================================================================
02. WHEN A METHOD IS CONSIDERED AS OVERLOADING METHOD?
If two methods hava same method name, those methods are considered as overloaded method.
RULES:
----------
* we should check is both methods must have different parameter type/list/order.
* But there is no rule on return type , Non-Accessibility Modifire and Accessibility Modifire
means overloading method can have its own return type, Non-Accessibility Modifire and
Accessibility Modifire because overloading methods are different methods.
==========================================================
03. WHEN WE SHOULD OVERLOAD A METHOD, WHAT ARE THE ADVANTAGES?
To execute same logic with different type of arguments we should overload methods.
ADVANTAGE
-----------------
If we overload method, user of our application gets comfort feeling in using method with an
impression that he/she calling only one method by passing different type of values.
the best example is "System.out.println();" method.
==========================================================
COLLECTION FRAMEWORK
---------------------------------------
01. WHAT IS COLLECTION, COLLECTION API & COLLECTION FRAMEWORK?
Collection is a container object, it is used for storing multiple homogeneous & heterogeneous,
unique & duplicate objects without size limitations and further used for sending all these
objects at a time from one class to another class as method argument and return value.
Collection is called Container object because it can contain other objects for storing and
transferring to other class methods.
==========================================================
02. IN WHAT SITUATION WE USE VARIABLE, CLASS, ARRAY, COLLECTION?
VARIABLE: We must use variable for storing one value of an object or an operation.
---------------
CLASS: We must use class for storing multiple values of an real world object.
----------
ARRAY: Array for storing multiple values of same type of an object property like courses,
---------- mobile number, emails.
COLLECTION : We must choose collection for storing multiple objects of a sigle class or
------------------- different class.
NOTE : Using Array we can also store objects but of same class.
Using Collection we can also store primitive values but as objects.
==========================================================
03. WHEN WE HAVE ARRAY FOR STORING OBJECTS WHY DO WE NEED
COLLECTION FOR STORING OBJECTS?
Array has 3 problems......
1. Only homogeneous objects are allowed.
2. Fixed in length , can not grow.
3. Does'nt have inbuilt method for performing different operations on array.
* To solve above 3 problems Collection API (classes) are invented.
* To solve Array first problem ie. Type problem we can simply choose jav.lang.Object[] object
* Since it is super class of all classes, we can store all type of java objects in this array.
* But size problem and inbuilt method operations problems can not be solve automatically
we must define or develop our own class with Object[] for storing object, with methods for
performing several operations on this array elements.
==========================================================
Java is a very simple, high level, Secured, Multithreaded, Platform independent, Object
Oriented Programing Language.
It was invented by "Gems Gosling" in SUN MICROSYSTEM for developing internet
applications.
==========================================================
2.WHY JAVA IS VERY SIMPLE?
its syntaxes are similar to c/c++.
it omits many of the features that makes c and c++ complex, confusing and unsafe.
java has inbuilt rich set of programs (API) sothat project development fast and easy.
Note: In java we don't implement most horrible topics such as pointers, structures, union,
operator overloading, multiple classes inheritance and many more.
==========================================================
3.IS JAVA SUPPORTS POINTERS?
Java doesn't supports pointer but internally pointers are there in java software [JVM].
Java native language is C that means java language is developed using C language so Java
software can have pointers internally.
==========================================================
4.WHERE JAVA IS USED?
* Desktop applications such as media player, antivirus and etc...
* Web applications such as Facebook.com, redbus.com and etc...
* Enterprise applications such as banking applications
* Mobile
* Embedded System
* Smartcard
* Robotics
* Games and etc...
==========================================================
5. WHEN SHOULD WE USE C AND WHEN SHOULD WE USE JAVA?
* we use C for developing system level and application level software's which are
stand-alone such as drivers, MS-office and etc...
* we use java only for developing application software(business applications) for
executing in different operating systems either as stand-alone or via network.
==========================================================
6. JAVA FEATURES
01. Simple 06. Object Oriented
02. Secure 07. Multithreaded
03. Robust 08. High Performance
04. Portable 09. Distributed
05. Architecture Natural 10. Dynamic
11. Byte codded
12. Interpreted
13. Garbage Collected
==========================================================
01. SIMPLE
------------
According to Sun, Java language is simple because:
syntax is based on C++ (so easier for programmers to learn it after C++).
removed many confusing and/or rarely-used features e.g., explicit pointers, operator
overloading etc.
No need to remove unreferenced objects because there is Automatic Garbage Collection in
java.
02. SICURE
-------------
Java is secured because:
No explicit pointer
Programs run inside virtual machine sandbox.
Class loader- adds security by separating the package for the classes of the local file system
from those that are imported from network sources.
Bytecode Verifier- checks the code fragments for illegal code that can violate access right to
objects.
Security Manager- determines what resources a class can access such as reading and writing
to the local disk.
These security are provided by java language. Some security can also be provided by
application developer through SSL, JAAS, cryptography etc.
03. ROBUST
-------------
Robust simply means strong. Java uses strong memory management. There are lack of pointers
that avoids security problem. There is automatic garbage collection in java. There is exception
handling and type checking mechanism in java. All these points makes java robust.
04. PORTABLE
----------------
We may carry the java bytecode to any platform.
05. ARCHITECTURAL NATURAL
---------------------------------------
There is no implementation dependent features e.g. size of primitive types is set.
06. OBJECT ORIENTED
-----------------------------
Object-oriented means we organize our software as a combination of different types of objects
that incorporates both data and behavior.
Object-oriented programming(OOPs) is a methodology that simplify software development
and maintenance by providing some rules.
Basic concepts of OOPs are:
Object
Class
Inheritance
Polymorphism
Abstraction
Encapsulation
07. MULTITHREADED
---------------------------
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 shares the same memory. Threads are important for multi-media,
Web applications etc.
08. HIGH PERFORMANCE
--------------------------------
Java is faster than traditional interpretation since byte code is "close" to native code still
somewhat slower than a compiled language (e.g., C++)
09. DISTRIBUTED
----------------------
We can create distributed applications in java. RMI and EJB are used for creating distributed
applications. We may access files by calling the methods from any machine on the internet.
10. DYNAMIC
-----------------
==========================================================
07. WHAT IS PLATFORM, PLATFORM DEPANDENCY & PLATFORM INDEPENDENCY?
PLATFORM
---------------
A platform is basically the hardware or software environment in which programs are loaded and runs
There are two types of platforms software-based and hardware-based. Java provides software-based
platform.
PLATFORM DEPENDENCY & INDEPENDENCY
--------------------------------------------------------------
When you develop a program in operating system if it is not executed in different os than
it is called Platform dependent,
if it is executed it is called Platform independent.
==========================================================
08.WHAT IS THE MEANING OF
1. SOURCE CODE
Developer written program, it is written according to the programming language syntax.
2.COMPILED CODE
Compiler generated program that is converted from source code.
3.EXECUTABLE CODE
Operating System understandable readily executable program.(.exe)
4. COMPILATION
It is a process of translating source code into compiled code.
5. EXECUTION
It is process of running compiled code to get output.
6. INTERPRETER
It is also translation program that converts source code into machine language but line by line.
7. COMPILER
It is a translation program that converts source code into machine language at once.
==========================================================
09. WHY C, C++ PROGRAMING LANGUAGES ARE PLATFORM DEPENDENT?
Because C, C++ program compiled code contains machine language of current operating
system whose format is not understandable to other operating system.
==========================================================
10. HOW JAVA ACHIEVED PLATEFORM INDEPENDENCY?
Java achieved platform independency by moving machine language generation from compilation
phase to execution phase by introducing "Byte code" and "JVM".
Byte Code is an intermediate language for all operating system it is native language for JVM.
JVM is a java platform, it runs java byte code by translating it into current operating system
machine languages.
==========================================================
11. WHY JVM PLATFORM DEPENDENT?
JVM is platform dependent because it takes java bytecodes and generates os dependent
machine language.
so java software is platform dependent, since JVM platform dependent.
we must have different java software for every operating system separately.
==========================================================
12. EXPLAIN WHY JAVA IS CALLED LANGUAGE, PLATFORM & TECHNOLOGY?
*JAVA is programming language because it is providing syntax and semantics for developing
new application.
*JAVA is a platform because it is providing its own runtime environment for executing java
programs that is JVM.
*JAVA is a technology because it is providing rich set of predefine programs for developing
project fast and easy.
==========================================================
JAVA SOFTWARE INTERVIEW QUESTION
-------------------------------------------------------
01. HOW MANY TYPE OF JAVA SOFTWARES DO WE HAVE?
JAVA software is divided into two parts
1. jdk (java development kit)
2. jre (java runtime environment)
note: jdk and jre are called principle products of java software.
==========================================================
02. WHAT IS THE DIFFERENCE BETWEEN JDK, JRE AND JIT?
JVM is a subset of JRE and JRE is the subset of JDK. When we install JDK, JRE also installed
automatically. JRE software is available as a separate pack, so we can install JRE alone.
JDK has both compiler and JVM. so using JDK we can develop, compile and execute new
java applications and also we can modify, compile and execute already developed applications.
JRE has only JVM hence using JRE we can only execute already developed applications.
==========================================================
03. WHAT IS THE MEANING OF MAJOR AND MINOR VERSION OF JAVA?
jdk 1.7.0 --------------------> major version
jdk1.7.0_01 |
jdk1.7.0_02 |
jdk1.7.0_03 |------> minor version
jdk1.7.0_04 |
jdk1.7.0_05 |
jdk1.7.0_06 |
==========================================================
04. WHY JAVA IS CALLED OPEN SOURCE SOFTWARE?
JAVA is open source because its source code comes with jdk installation.
==========================================================
ENVIRONMENT VARIABLES INTERVIEW QUESTIONS
------------------------------------------------------------------------
01. WHAT IS THE ENVIRONMENT VARIABLE?
The variable created in operating system to store software's binary and library files are called
environment variable.
==================================================================
02. WHAT IS THE DIFFERENCE BETWEEN BINARY FILES AND LIBRARY FILES?
Binary Files- are command files by default stored in a folder called "bin".
Library Files- are program files by default stored in a folder called "lib".
==================================================================
03. WHAT IS THE DIFFERENCE BETWEEN PATH, CLASSPATH AND JAVA_HOME?
Path is a mediator between developer and operating system to inform software binary files path.
Class Path is a mediator between developer and compiler , JVM to inform the library files
path those are used in our source code.
JAVA_HOME -the Java software installed directory is called JAVA_HOME.
==================================================================
04.WHY "PATH" IS USED BY OS AND WHY CLASS PATH IS USED BY COMPILER AND JVM?
Path is used for locating a software's binary files. PATH is used by OS for finding the binary files.
Class path is used for identifying library file of a software. It is used by compiler and JVM for identifying
java classes path.
==================================================================
05. WHO WILL USE JAVA_HOME?
JAVA_HOME used for locating JVM software installed directory. It is used by programmer
or a server software like tomcat for identifying java software installed directory.
==========================================================
JAVA PROGRAMMING INTERVIEW QUESTIONS
---------------------------------------------------------------
01. WHAT ARE THE 10 PROGRAMMING ELEMENTS OF JAVA LANGUAGE?
1. package
2. class
3. interface
4. abstract
5. enum
6. annotation
7. variables
8. method
PACKAGE is a folder that is linked with .class . It is used for grouping related classes and
interfaces also used for separating new classes from existing class if both have same name.
CLASS is a top level block which is used for grouping variables and methods.
CLASS is a blue print of an object that represents group of objects of same type.
it is called blue print becoz it represent many object of same type.
OBJECT is a real-world thing which is an instance of a class in java.
INSTANCE - Object is an instance of an class means for storing object data some
memory is allocated from the class this memory is called instance.
==========================================================
OBJECT ORIENTED PROGRAMMIN
--------------------------------------------------
01. WHAT IS OOP WHY OOP?
OOP is a methodology. It provides suggestion for implementing real-world object in programming
world.
OOP concepts are given for implementing real world object in programming world for automatic
real-world business operation by achieving security and dynamic method dispatching.
* For representing real world OOP has a concept called class.
* For achieving security OOP has a concept is encapsulation.
* For achieving DMD OOP has concept abstraction, inheritance, polymorphism.
=>Representing an object mean creating a class with this object name, with variable and method for
storing value of this object and for implementing its operation.
=>Achieving security means not allowed me other programmer to access object data directly,
allow me other programmer access object data with an proper validation and authentication.
=>Achieve DMD means calling a method and executing it dynamically from different subclass
of subtype based on subclass is passed.
Example for DMD:
----------------------
We have one ATM machine we can withdraw money from this ATM machine from or
using any Bank ATM Card this phenomena is called DMD.
Advantage of DMD
------------------------
We can develop single user class for achieving services from different subclass of
same type of an object.
=============================================================================
02. INSTEAD DEVELOPPING OOP CONCEPT IN STRUCTURE ORIENTED PROGRAMMING
LANGUAGES WHY SAPERATE LANGUAGES ARE INVENTED?
In OOP concept programming style is class based, structure programming function based
if we want to implement OOP Concept in structure program we must rebuilt previously
developed applications.
==================================================================
03. WHAT IS OOP PRINCIPLE?
OOP principles are suggestions, they provide a way to implement an object by achieving
security to data, Reusability in functionality, Achieving runtime polymorphism(DMD).
we have 3 OOP Principles
1. Encapsulation
2. Inheritance
3. Polymorphism
We also have another principle called Abstraction. It is object modeling principle.
By following Abstraction we will declare object, than by following Encapsulation,
Inheritance, Polymorphism we will implement those operations by achieving SRR-
security reusability runtime polymorphism.
===================================================================
04. WHAT IS ENCAPSULATION?
Encapsulation is the process of creating a class with variables and methods as a single group
or unit, providing access to these variables or data by a these methods with a proper validation
and calculation is called encapsulation.
"protecting object data from direct accessing by user."
==================================================================
05. WHAT IS INHERITANCE?
Inheritance is the process of creating a new class driving from an existing class for obtaining
properties and behaviors of an object to this new object to treat it as an existing object.
==================================================================
06. WHAT IS POLYMORPHISM?
Polymorphism means having multiple forms, so by following polymorphism we are defining
multiple methods with same name either with same implementation or different implementation.
"providing multiple implementation to the same method."
===================================================================
07. WHAT IS ABSTARTION?
Abstraction is a process of creating a class "by hiding implementation details of a method
operations, providing only necessary information for accessing this method operation."
"hiding implementation details of a method from user programmer."
==================================================================
08. WHAT IS THE ADVANTAGES OF INHERITANCE?
1. Obtaining type.
2. Code reusability.
3. Overriding.
4. Extending.
5. Implementing.
6. Loose coupling and Runtime Polymorphism.
==================================================================
09. HOW CAN WE DEVELOP INHERITANCE IN JAVA?
We can develop inheritance in Java using
1. extends
2. implements keywords
extends
--------
* It is used to provide reusability to subclass for accessing and executing methods given in
subclass.
* It is allowed between two classes or two interfaces for developing inheritance.
implements
--------------
* It provides forcibility to subclass for implementing logic to the methods given in subclass.
* It can be used only for driving subclass from super interface.
===================================================================
10. WHEN SHOULD WE DEVELOP INHERITANCE?
When we find multiple object of same type having same property and behaviors with different
implementation. We must develop these object classes with inheritance.
==================================================================
METHOD HIDING & OVERRIDING
---------------------------------------------
01. WHAT IS THE MEANING OF METHOD HIDING?
Redefining super class static method in subclass with same prototype is called "method hiding".
==================================================================
02. WHAT IS THE MEANING OF METHOD OVERRIDING?
Redefining super class Non-static method in subclass with same prototype is called "method
overriding".
==================================================================
03. WHEN SHOULD WE OVERRIDE SUPER CLASS METHOD IN SUBCLASS?
If the super class method logic is not fulfilling subclass business requirements, sub class should
override that method with required business logic. Usually in super class, methods are defined with generic logic which is common for all subclasses.
the best example is toString() method.
==================================================================
04. IN SUBCLASS WHEN A METHOD IS CONSIDERED AS OVERRIDING METHOD?
If a method in sub class contains signature same as super class non private method, sub class
method is treated as overriding method and super class method is treated as overridden
method.
==================================================================
05. WHAT ARE THE 4 RULES WE MUST FOLLOW IN METHOD OVERRIDING?
Rules are:
1. RETURN TYPE should be same as super class method.
2. STATIC MODIFIER should not be removed or added.
3. ACCESSIBILITY MODIFIER should be same as super class method or it can be increased
but should not be decreased.
private, default, protected, public.
FOCUS:
----------
We can not override private method because it is not inherited to subclass.If we override
it in subclass no CE and it is not considered ass overriding method, it is just considered
as subclass own method. so this method can have its own return type NAM and AM.
4.THROWS CLOUSE should not be added with checked exception if super class does not
contains it. If super class method contain throws clouse, subclass overriding method should
contain throws clouse with same exception class or its sub class or it can be removed.
==================================================================
05.WHAT IS CO-VARIANT RETURN METHOD?
Now, since java5, it is possible to override any method by changing the return type if the return type of the subclass overriding method is subclass type. It is known as covariant return type.
==========================================================
METHOD OVERLOADING
-----------------------------------
01. WHAT IS METHOD OVERLOADING?
Difining multiple methods with the same name but different parameter type/list/order is called
method overloading.
==================================================================
02. WHEN A METHOD IS CONSIDERED AS OVERLOADING METHOD?
If two methods hava same method name, those methods are considered as overloaded method.
RULES:
----------
* we should check is both methods must have different parameter type/list/order.
* But there is no rule on return type , Non-Accessibility Modifire and Accessibility Modifire
means overloading method can have its own return type, Non-Accessibility Modifire and
Accessibility Modifire because overloading methods are different methods.
==========================================================
03. WHEN WE SHOULD OVERLOAD A METHOD, WHAT ARE THE ADVANTAGES?
To execute same logic with different type of arguments we should overload methods.
ADVANTAGE
-----------------
If we overload method, user of our application gets comfort feeling in using method with an
impression that he/she calling only one method by passing different type of values.
the best example is "System.out.println();" method.
==========================================================
COLLECTION FRAMEWORK
---------------------------------------
01. WHAT IS COLLECTION, COLLECTION API & COLLECTION FRAMEWORK?
Collection is a container object, it is used for storing multiple homogeneous & heterogeneous,
unique & duplicate objects without size limitations and further used for sending all these
objects at a time from one class to another class as method argument and return value.
Collection is called Container object because it can contain other objects for storing and
transferring to other class methods.
==========================================================
02. IN WHAT SITUATION WE USE VARIABLE, CLASS, ARRAY, COLLECTION?
VARIABLE: We must use variable for storing one value of an object or an operation.
---------------
CLASS: We must use class for storing multiple values of an real world object.
----------
ARRAY: Array for storing multiple values of same type of an object property like courses,
---------- mobile number, emails.
COLLECTION : We must choose collection for storing multiple objects of a sigle class or
------------------- different class.
NOTE : Using Array we can also store objects but of same class.
Using Collection we can also store primitive values but as objects.
==========================================================
03. WHEN WE HAVE ARRAY FOR STORING OBJECTS WHY DO WE NEED
COLLECTION FOR STORING OBJECTS?
Array has 3 problems......
1. Only homogeneous objects are allowed.
2. Fixed in length , can not grow.
3. Does'nt have inbuilt method for performing different operations on array.
* To solve above 3 problems Collection API (classes) are invented.
* To solve Array first problem ie. Type problem we can simply choose jav.lang.Object[] object
* Since it is super class of all classes, we can store all type of java objects in this array.
* But size problem and inbuilt method operations problems can not be solve automatically
we must define or develop our own class with Object[] for storing object, with methods for
performing several operations on this array elements.
==========================================================
Comments
Post a Comment