SlideShare uma empresa Scribd logo
1 de 15
java interview Questions
Here's some more java questions:
1) Junior java developer
a) Basic ocjp (former scjp) questions:
– What does static,final mean,purposes;
– How many accesibilitymodifiers exist? Please describe them.
– Why do you need a main method?
– How many constructors can you have?
– Define overwriting and overloading
– Give java API implementations for overwriting and overloading
– Describe the String class – unique properties
– StringBuilder vs StringBuffer
– Collections :please describe,give some examples and compare them to eachother
– ArrayList vs Vector
– HashMap vs HashTable
– What’s a tree
– What’s a map
– Multithreading:describe the managementin java
– What’s a semaphone?
– How many states are there for threads?
– Describe the usage for synchronized word (2)
– Serialization in java – a descrition and usage
– Garbage collection in java – description and usage
– Can you guarantee the garbage collection process?
b) Simple design pattern questions:
– Singleton please describe main features and coding
– Factory please describe main features and coding
– Have you used others? please describe them
2) Intermediate and Senior level – depending on rate of good responses,additional questions to 1):
http://centraladvisor.com/programming-2/java/java-developer-interview
Bogdan 08-1-2012 10:34 AM
Java interview questions and answers
Explain the importance of DriverManager.
The basic service to manage setof JDBC drivers.
What are the methods in Object?
clone,equals,wait,finalize, getClass,hashCode,notify, notifyAll, toString
Define a nested class.
If all the methods ofa inner class is static then it is a nested class.
What is garbage collection?
Reclaiming the unused memoryby the invalid objects.Garbage collector is res ponsible for this process
Difference betweenLinkedList and ArrayList.
LinkedListare meantfor sequential accessing.
ArrayList are meantfor random accessing.
Define a package.
Packages provides wide namespace abilityand allows to group setof classes into a single unit.
Raj 12-5-2011 03:10 AM
Java interview questions and answers
Explain the significance of ListIterator.
Using ListIterator you can iterate back and forth.
Can you explain inner class.
If the methods ofthe inner class can only be accessed via the instance ofthe inner class,then it is called inner class.
Can you explain the meaning of aggregation and composition
Aggregation - It is a special type of composition.Ifyou expose all the methods ofa composite class and route the method call to the
composite method through its
reference,then it is called aggregation.
Composition - Holding the reference of the other class within some other class is known as composition.
Is it possible to instantiate the Math class?
You can’tinstantiate the math class.
Pankaj 12-5-2011 03:10 AM
Java interview questions and answers
Define Locale.
A Locale objectrepresents a specific geographical,political,or cultural region.
How will you load a specific locale?
By using ResourceBundle.getBundle(…);
Is JVM a compiler or an interpreter?
Interpreter
Can you explain the usages of Class.forName()?
It loads the class into the ClassLoader.It returns the Class.Using thatyou can get the instance ( “class -instance”.newInstance() ).
Inq adds a question:Expain the reason for each keyword of
public static void main(String args[])
Akash 12-5-2011 03:10 AM
Java interview questions and answers
Define reflection.
Reflection allows programmatic access to information aboutthe fields,methods and constructors ofloaded classes.
Can you tell me range of byte?
128 to 127
How to invoke externalprocess in Java.
Runtime.getRuntime().exec(….)
What is the best way to findout the time/memory consuming process?
By using profiler
Rakesh 12-5-2011 03:09 AM
Java interview questions and answers
What is skeleton and stub? Explain their purposes.
Stub is a clientside representation ofthe server, which takes care of communicating with the remote server.
What kind of thread is the Garbage collector thread?
Daemon thread
Explain the purpose of Void class.
The Void class is an uninstantiable placeholder class to hold a reference to the Class objectrepresenting the primitive Java type void.
Nitin 12-5-2011 03:09 AM
Java interview questions and answers
Explain the importance of finalize method.
Finalize method cleans up some resources before itgetgarbage collected.
Define mutable object and immutable object.
The value of Mutable object is changeable.
Ex., StringBuffer
The value of an immutable objectcan'tbe changed
Ex., String, Integer, Float
What are the base class for Error and Exception?
Throwable
Dharam 12-5-2011 03:09 AM
Java interview questions and answers
Difference betweenstring and stringbuffer object.
String is an immutable object.
StringBuffer is a mutable object.
Define daemon thread.
Daemon thread are the threads which can run withoutuser intervention.
The JVM can exit when there are daemon thread by killing them abruptly.
Define a DatabaseMetaData.
It represents comprehensive information aboutthe database as a whole.
Jitu 12-5-2011 03:08 AM
Java interview
Explain preemptive scheduling and time slicing.
In preemptive scheduling,the highestpriority task executes until it enters the waiting or dead states or a higher priority task comes into
existence.
In time slicing,a task executes for a predefined slice oftime and then reenters the pool of ready tasks.
Explain the different scopes for Java variables.
3 scopes ofJava variables are defined below:
Instance
Initialized to defaultvalues at the time of creation of object, and remain accessible as long as the objectaccessible.
Local
Defined within a method and remain accessbile onlyduring the course of method excecution and fall out of scope When the method fin
execution.
Static
Static variables are the class level variables.
Static variables are initialized when the class is loaded in JVM for the firsttime and remain there as long as the class remains loaded.
Static variables are not tied to any particular objectinstance.
Akash 11-23-2011 02:26 AM
Java interview questions and answers
Explain the purpose of finalization.
It provides an unreachable objectthe opportunity to perform any cleanup processing before the objectis garbage collected.
Explain the importance of daemon thread.
Daemon thread is a low priority thread.
It runs intermittentlyin the back ground doing the garbage collection operation for the java runtime system.
A daemon thread is created using setDaemon method.
Synchronized methods and synchronized statements.
Synchronized methods
Methods that are used to control access to an object.
A thread only executes a synchronized method after it has acquired the lock for the method's objector class.
Synchronized statements
They are similar to synchronized methods.
A synchronized statementcan only be executed after a thread has acquired the lock for the object or class referenced in the synchroni
statement.
Nitin 11-23-2011 01:31 AM
Java interview questions and answers
What are the way of using thread?
Can be implemented byusing runnable interface
By inheriting from the Thread class.
Difference betweena constructor and a method.
Constructor
A constructor is a member function ofa class thatis used to create objects ofthat class.
It has the same name as the class itself.
It has no return type, and is invoked using the new operator.
Method
A method is an ordinary member function of a class.
It has its own name,a return type, and is invoked using the dot operator.
Explain how to serialize an object to a file.
The class whose instances are to be serialized should implementan interface Serializable,pass the instance to the ObjectOutputStrea
which is connected to a fileoutputstream.This will save the objectto a file.
Naveen 11-23-2011 01:25 AM
Java questions and answers
Access Specifiers in Java.
Public- public classes,methods,and fields can be accessed from everywhere.
Protected-
Protected methods and fields can onlybe accessed within the same class,within its subclasses,and within classes ofthe sam e packa
Default(no specifier)
Such a class,method,or field will be accessible from inside the same package to which the class,method,or field belongs,butnotfrom
outside this package.
Private
Private methods and fields can onlybe accessed within the same class.
Private methods and fields are notvisible within subclasses
They are not inherited by subclasses.
Explain static methods.
Static methods are declared with the keyword static as modifier.
They are called Static because they affect a class as a whole,not a particular instance ofthe class.
They are always invoked without reference to a particular instance ofa class.
Restrictions ofusing static methods:
It can only call other static methods.
It mustonly access static data.
It cannotreference to the current objectusing keywords super or this.
Priya 11-23-2011 12:55 AM
Java interview questions
Can you tell me the main Implementations of the Set interface?
HashSet
TreeSet
LinkedHashSet
EnumSet
Explain the importance of HashSet.
It is an unsorted,unordered Set.
It uses the hashcode ofthe objectbeing inserted.
You can use it when you want a collection with no duplicates and you don’tcare about order when you iterate through it.
Explain the importance of TreeSet.
It is a setimplementation keeping the elements in sorted order.
The elements are sorted according to the natural order of elements or by the comparator provided at creation time.
Tina 11-23-2011 12:46 AM
Java interview questions and answers
Define native method.
A native method is implemented in a language other than Java.
Explain explicit casting.
In Explicit casting,the complier are specificallyinformed abouttransforming the object.
Example
long a = 890.20;
int b = (int) a; //Explicit casting
Explain implicit casting.
Assigning one entity to another without any transformation guidance to the compiler is implicitcasting.
This type of casting is not permitted in all kinds of transformations and maynotwork for all scenarios.
Example
int a = 6000;
long b = a; //Implicitcasting
Explain reflection API
Reflection is the process ofintrospecting the features and state of a class atruntime and dynamicallymanipulate atrun time.
This is supported using Reflection APIwith built-in classes like Class,Method, Fields,Constructors etc.
Example:Using Java Reflection API we can get the class name, byusing the getName method.
Rajeev 11-22-2011 04:07 AM
Java interview questions and answers
Explain the importance of Java Virtual Machine (JVM).
It converts .java file into .class file by using Compiler and Interpreter reads byte codes.
Explain the different types of access modifiers in Java.
They determine the type of access to the member ofa class.
Types:
-Public : accessible to all classes
-Protected : accessible to the classes within the same package and anysubclasses.
-Private : accessible onlyto the class to which they belong
-Default: accessible to the class to which they belong and to subclasses within the same package
Why there are no global variables in Java?
Global variables are globallyaccessible and hence can create collisions in namespace.
What is the Java API?
It a large collection of software components thatprovide capabilities,such as graphical user interface (GUI) widgets.
Rajeev 11-22-2011 03:48 AM
Java interview questions and answers
Explain StringTokenizer.
It is utility class thatare used to break up string.
Example:
StringTokenizer str = new StringTokenizer(“Welcome”);
while (str.hasMoreTokens()) {
System.out.println(st.nextToken());
}
Nadeem 11-22-2011 03:42 AM
Java interview questions and answers
Difference betweenthe boolean & operator and the && operator.
When boolean & operator is evaluated, both operands are evaluated
&& operator is a shortcut operator.
When && operator is evaluated, the first operand is evaluated.
When firstoperand returns a value of true then the second operand is evaluated.
When firstoperand evaluates to false,the evaluation of the second operand is skipped.
Nadeem 11-22-2011 03:40 AM
Java interview questions
Does Java supportpointers?
Java doesn'tsupportthe usage ofpointers.Improper handling ofpointers leads to memoryleaks which is whypointer concept hasn't fo
place in Java.
Swing and Awt
AWT are heavy-weight componenets.
Swings are light-weightcomponents and this is reason whyswing works faster than AWT.
Pass by reference and passbyvalue
Pass By Reference is the passing the address itselfrather than passing the value.
PassbyValue is passing a copy of the value to be passed.
Rakesh S 11-4-2011 01:26 AM
Java interview questions
Abstract class
It mustbe extended or subclassed.
It acts as a template.
It may contain static data.
A class maybe declared abstracteven if it has no abstractmethodsand this prevents itfrom being instantiated.
Annie 11-4-2011 01:21 AM
Java interview questions and answers - April 18, 2011
What is an abstract method?
An abstractmethod is a method which doesn’thave a body, justdeclared with modifier abstract.
Explain the use of the finally block.
Finally block is a block which always executes. The block executes even when an exception is occurred. The block
won't execute only when the user calls System.exit()
What is the initial state of a thread?
It is in a ready state.
What is time slicing?
In time slicing,the task continues its execution for a predefined period oftime and reenters the pool of ready tasks.
What are Wrapper Classes?
Wrapper Classes allow to access primitives as objects.
What is List interface?
Listis an ordered collection ofobjects.
Can you explain transient variables in java?
They are the variables thatcannot be serialized.
What is synchronization?
Synchronization ensures onlyone thread to access a shared resource,thus controls the access ofmultiple threads to
shared resources.
What is serialization?
Serialization helps to convert the state of an object into a byte stream.
What is HashMap and Map?
Map is Interface and Hashmap is class thatimplements that.
Java interview questions and answers - April 20,
2011
What is StringBuffer class?
StringBuffer class is same as String class with the exception that it is mutable.It allows change and doesn’tcreate a
new instance on change of value.
How can you force garbage collection?
It is not possible to force GC. We can justrequestitby calling System.gc().
Is it possible an exception to be rethrown?
Yes, an exception can be rethrown.
What is the return type of a program’s main() method?
A program’s main() method has a void return type.
Which package is always imported by default?
The java.lang package is always imported by default.
What is a Class?
A class implements the behavior of member objects bydescribing all the attributes of objects and the methods.
What is an Object?
An objectis the members ofa class.It is the basic unitof a system.It has attributes,behavior and identity.
Explain the use of "instanceOf" keyword.
"instanceOf"keyword is used to check the type of object.
How do you refer to a current instance of object?
You can refer the current instance of objectusing "this"keyword.
What is the use of JAVAP tool?
JAVAP is used to disassemble compiled Java files.This option is useful when original source code is notavailable.
In which package is the applet class located?
Applet classes are located in "java.applet"package.
Java array vs. ArrayList class.
ArrayList is a dynamic array that can grow depending on demand whereas Java arrays are fixed length.
Explain Enumeration Interface.
It defines the methods using which we can enumerate the elements in a collection ofobjects.
What are access modifiers?
Access modifiers determine ifa method or a data variable can be accessed byanother method in another class.
Explain the impact of private constructor.
Private constructor prevents a class from being explicitlyinstantiated by callers.
What is an exception?
An exception is an abnormal condition thatarises in a code sequence atrun time
Java interview questions and answers - April 21,
2011
What are ways to create threads?
There are two ways to create a thread:
extend the java.lang.Thread class
implementthe java.lang.Runnable interface
How can we stop a thread programmatically?
thread.stop;
What are daemon threads?
Daemon threads are designed to run in background.An example of such thread is garbage collector thread.
What are the different types of locks in JDBC?
There are four types of major locks in JDBC:
Exclusive locks
Shared locks
Read locks
Update locks
What are Servlets?
Servlets are program that run under web server environments.
What are the different ways to maintain state between requests?
There are four different ways:
URL rewriting
Cookies
Hidden fields
Sessions
What are wrapper classes?
In Java we have classes for each primitive data types. These classes are called as wrapper class.For e xample,
Integer, Character,Double etc.
What are checked exceptions?
There are exceptions that are forced to catch by Java compiler,e.g IOException. Those exceptions are called
checked exceptions.
What is the Locale class?
Locale class is a class thatconverts the program outputto a particular geographic,political,or cultural region
Is main a keyword in Java?
No, main is nota keyword in Java.
What is the most important feature of Java?
Platform independencymakes Java a premium language.
What is a JVM?
JVM is Java Virtual Machine which is a run time environmentfor the compiled java class files.
Does Java support multiple inheritances?
No, Java doesn'tsupportmultiple inheritances.
What is the base class of all classes?
java.lang.Object
Can a class be declared as protected?
A class can'tbe declared as protected.Only methods can be declared as protected.
Can an abstract class be declared final?
No, since it is obvious that an abstract class withoutbeing inherited is ofno use.
Java interview questions and answers - April 22,
2011
Can we declare a variable as abstract?
Variables can't be declared as abstract.Only classes and methods can be declared as abstract.
Define Marker Interface.
An Interface which doesn'thave any declaration inside butstill enforces a mechanism.
What is an abstract method?
An abstractmethod is a method whose implementation is deferred to a subclass.
When can an object reference be cast to an interface reference?
An objectreference is cast to an interface reference when the object implements the referenced interface.
Which class is extended by all other classes?
The Object class is extended by all other classes.
What is the return type of a program's main() method?
void.
What are the eight primitive Java types?
The eightprimitive types are byte, char, short,int, long, float, double,and boolean.
Difference between a public and a non-public class.
A public class maybe accessed outside ofits package.A non-public class maynotbe accessed outside ofits
package.
Which Java operator is right associative?
The = operator is right associative.
What is a transient variable?
Transientvariable is a variable that may not be serialized.

Mais conteúdo relacionado

Mais procurados

Most Asked Java Interview Question and Answer
Most Asked Java Interview Question and AnswerMost Asked Java Interview Question and Answer
Most Asked Java Interview Question and AnswerTOPS Technologies
 
Java questions for interview
Java questions for interviewJava questions for interview
Java questions for interviewKuntal Bhowmick
 
Java tutorials
Java tutorialsJava tutorials
Java tutorialssaryu2011
 
SQL Interview Questions For Experienced
SQL Interview Questions For ExperiencedSQL Interview Questions For Experienced
SQL Interview Questions For Experiencedzynofustechnology
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaCPD INDIA
 
Java Interview Questions For Freshers
Java Interview Questions For FreshersJava Interview Questions For Freshers
Java Interview Questions For Fresherszynofustechnology
 
Java Faqs useful for freshers and experienced
Java Faqs useful for freshers and experiencedJava Faqs useful for freshers and experienced
Java Faqs useful for freshers and experiencedyearninginjava
 
Core java notes with examples
Core java notes with examplesCore java notes with examples
Core java notes with examplesbindur87
 
Object Oriented Programming using JAVA Notes
Object Oriented Programming using JAVA Notes Object Oriented Programming using JAVA Notes
Object Oriented Programming using JAVA Notes Uzair Salman
 
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...Sagar Verma
 
Java oops and fundamentals
Java oops and fundamentalsJava oops and fundamentals
Java oops and fundamentalsjavaease
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Javabackdoor
 
Core Java interview questions-ppt
Core Java interview questions-pptCore Java interview questions-ppt
Core Java interview questions-pptMayank Kumar
 

Mais procurados (19)

7. Multithreading
7. Multithreading7. Multithreading
7. Multithreading
 
Most Asked Java Interview Question and Answer
Most Asked Java Interview Question and AnswerMost Asked Java Interview Question and Answer
Most Asked Java Interview Question and Answer
 
Java questions for interview
Java questions for interviewJava questions for interview
Java questions for interview
 
Java tutorials
Java tutorialsJava tutorials
Java tutorials
 
SQL Interview Questions For Experienced
SQL Interview Questions For ExperiencedSQL Interview Questions For Experienced
SQL Interview Questions For Experienced
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in java
 
Java Interview Questions For Freshers
Java Interview Questions For FreshersJava Interview Questions For Freshers
Java Interview Questions For Freshers
 
Java Faqs useful for freshers and experienced
Java Faqs useful for freshers and experiencedJava Faqs useful for freshers and experienced
Java Faqs useful for freshers and experienced
 
Packages
PackagesPackages
Packages
 
Unit 3 Java
Unit 3 JavaUnit 3 Java
Unit 3 Java
 
Core java notes with examples
Core java notes with examplesCore java notes with examples
Core java notes with examples
 
Object Oriented Programming using JAVA Notes
Object Oriented Programming using JAVA Notes Object Oriented Programming using JAVA Notes
Object Oriented Programming using JAVA Notes
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
 
Access modifiers
Access modifiersAccess modifiers
Access modifiers
 
Java oops and fundamentals
Java oops and fundamentalsJava oops and fundamentals
Java oops and fundamentals
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 
OOPs in Java
OOPs in JavaOOPs in Java
OOPs in Java
 
Core Java interview questions-ppt
Core Java interview questions-pptCore Java interview questions-ppt
Core Java interview questions-ppt
 

Semelhante a Top 40 Java interview questions

Top 20 Core Java Interview Questions & Answers for Selenium Automation Testin...
Top 20 Core Java Interview Questions & Answers for Selenium Automation Testin...Top 20 Core Java Interview Questions & Answers for Selenium Automation Testin...
Top 20 Core Java Interview Questions & Answers for Selenium Automation Testin...AnanthReddy38
 
Java interview questions and answers for cognizant By Data Council Pune
Java interview questions and answers for cognizant By Data Council PuneJava interview questions and answers for cognizant By Data Council Pune
Java interview questions and answers for cognizant By Data Council PunePankaj kshirsagar
 
25 java interview questions
25 java interview questions25 java interview questions
25 java interview questionsMehtaacademy
 
Top 371 java fa qs useful for freshers and experienced
Top 371 java fa qs useful for freshers and experiencedTop 371 java fa qs useful for freshers and experienced
Top 371 java fa qs useful for freshers and experiencedGaurav Maheshwari
 
oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfArpitaJana28
 
Nitish Chaulagai Java1.pptx
Nitish Chaulagai Java1.pptxNitish Chaulagai Java1.pptx
Nitish Chaulagai Java1.pptxNitishChaulagai
 
Java Interview Questions
Java Interview QuestionsJava Interview Questions
Java Interview QuestionsKuntal Bhowmick
 
Top 20 Core Java Interview Questions & Answers for Selenium Automation Testin...
Top 20 Core Java Interview Questions & Answers for Selenium Automation Testin...Top 20 Core Java Interview Questions & Answers for Selenium Automation Testin...
Top 20 Core Java Interview Questions & Answers for Selenium Automation Testin...AnanthReddy38
 
Dev labs alliance top 20 basic java interview questions for sdet
Dev labs alliance top 20 basic java interview questions for sdetDev labs alliance top 20 basic java interview questions for sdet
Dev labs alliance top 20 basic java interview questions for sdetDevLabs Alliance
 
Object oriented programming tutorial
Object oriented programming tutorialObject oriented programming tutorial
Object oriented programming tutorialGhulam Abbas Khan
 
Android Training (Java Review)
Android Training (Java Review)Android Training (Java Review)
Android Training (Java Review)Khaled Anaqwa
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .NetGreg Sohl
 

Semelhante a Top 40 Java interview questions (20)

Java mcq
Java mcqJava mcq
Java mcq
 
PPT Lecture-1.4.pptx
PPT Lecture-1.4.pptxPPT Lecture-1.4.pptx
PPT Lecture-1.4.pptx
 
Top 20 Core Java Interview Questions & Answers for Selenium Automation Testin...
Top 20 Core Java Interview Questions & Answers for Selenium Automation Testin...Top 20 Core Java Interview Questions & Answers for Selenium Automation Testin...
Top 20 Core Java Interview Questions & Answers for Selenium Automation Testin...
 
Java interview questions and answers for cognizant By Data Council Pune
Java interview questions and answers for cognizant By Data Council PuneJava interview questions and answers for cognizant By Data Council Pune
Java interview questions and answers for cognizant By Data Council Pune
 
Java_Interview Qns
Java_Interview QnsJava_Interview Qns
Java_Interview Qns
 
Suga java training_with_footer
Suga java training_with_footerSuga java training_with_footer
Suga java training_with_footer
 
25 java interview questions
25 java interview questions25 java interview questions
25 java interview questions
 
Top 371 java fa qs useful for freshers and experienced
Top 371 java fa qs useful for freshers and experiencedTop 371 java fa qs useful for freshers and experienced
Top 371 java fa qs useful for freshers and experienced
 
oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdf
 
Nitish Chaulagai Java1.pptx
Nitish Chaulagai Java1.pptxNitish Chaulagai Java1.pptx
Nitish Chaulagai Java1.pptx
 
Java ppt
Java pptJava ppt
Java ppt
 
Java Interview Questions
Java Interview QuestionsJava Interview Questions
Java Interview Questions
 
Top 20 Core Java Interview Questions & Answers for Selenium Automation Testin...
Top 20 Core Java Interview Questions & Answers for Selenium Automation Testin...Top 20 Core Java Interview Questions & Answers for Selenium Automation Testin...
Top 20 Core Java Interview Questions & Answers for Selenium Automation Testin...
 
Dev labs alliance top 20 basic java interview questions for sdet
Dev labs alliance top 20 basic java interview questions for sdetDev labs alliance top 20 basic java interview questions for sdet
Dev labs alliance top 20 basic java interview questions for sdet
 
Object oriented programming tutorial
Object oriented programming tutorialObject oriented programming tutorial
Object oriented programming tutorial
 
Android Training (Java Review)
Android Training (Java Review)Android Training (Java Review)
Android Training (Java Review)
 
Chapter 8 java
Chapter 8 javaChapter 8 java
Chapter 8 java
 
Oops
OopsOops
Oops
 
Core_Java_Interview.pdf
Core_Java_Interview.pdfCore_Java_Interview.pdf
Core_Java_Interview.pdf
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .Net
 

Último

Insurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageInsurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageMatteo Carbone
 
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLMONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLSeo
 
The Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case studyThe Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case studyEthan lee
 
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service AvailableDipal Arora
 
Call Girls in Gomti Nagar - 7388211116 - With room Service
Call Girls in Gomti Nagar - 7388211116  - With room ServiceCall Girls in Gomti Nagar - 7388211116  - With room Service
Call Girls in Gomti Nagar - 7388211116 - With room Servicediscovermytutordmt
 
Eni 2024 1Q Results - 24.04.24 business.
Eni 2024 1Q Results - 24.04.24 business.Eni 2024 1Q Results - 24.04.24 business.
Eni 2024 1Q Results - 24.04.24 business.Eni
 
Call Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine ServiceCall Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine Serviceritikaroy0888
 
BEST ✨ Call Girls In Indirapuram Ghaziabad ✔️ 9871031762 ✔️ Escorts Service...
BEST ✨ Call Girls In  Indirapuram Ghaziabad  ✔️ 9871031762 ✔️ Escorts Service...BEST ✨ Call Girls In  Indirapuram Ghaziabad  ✔️ 9871031762 ✔️ Escorts Service...
BEST ✨ Call Girls In Indirapuram Ghaziabad ✔️ 9871031762 ✔️ Escorts Service...noida100girls
 
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
Keppel Ltd. 1Q 2024 Business Update  Presentation SlidesKeppel Ltd. 1Q 2024 Business Update  Presentation Slides
Keppel Ltd. 1Q 2024 Business Update Presentation SlidesKeppelCorporation
 
Monthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxMonthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxAndy Lambert
 
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130  Available With RoomVIP Kolkata Call Girl Howrah 👉 8250192130  Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Roomdivyansh0kumar0
 
Grateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdfGrateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdfPaul Menig
 
Regression analysis: Simple Linear Regression Multiple Linear Regression
Regression analysis:  Simple Linear Regression Multiple Linear RegressionRegression analysis:  Simple Linear Regression Multiple Linear Regression
Regression analysis: Simple Linear Regression Multiple Linear RegressionRavindra Nath Shukla
 
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...anilsa9823
 
A DAY IN THE LIFE OF A SALESMAN / WOMAN
A DAY IN THE LIFE OF A  SALESMAN / WOMANA DAY IN THE LIFE OF A  SALESMAN / WOMAN
A DAY IN THE LIFE OF A SALESMAN / WOMANIlamathiKannappan
 
Catalogue ONG NUOC PPR DE NHAT .pdf
Catalogue ONG NUOC PPR DE NHAT      .pdfCatalogue ONG NUOC PPR DE NHAT      .pdf
Catalogue ONG NUOC PPR DE NHAT .pdfOrient Homes
 
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesMysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesDipal Arora
 
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service DewasVip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewasmakika9823
 
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call GirlsCash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call GirlsApsara Of India
 

Último (20)

Insurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageInsurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usage
 
Forklift Operations: Safety through Cartoons
Forklift Operations: Safety through CartoonsForklift Operations: Safety through Cartoons
Forklift Operations: Safety through Cartoons
 
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLMONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
 
The Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case studyThe Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case study
 
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
 
Call Girls in Gomti Nagar - 7388211116 - With room Service
Call Girls in Gomti Nagar - 7388211116  - With room ServiceCall Girls in Gomti Nagar - 7388211116  - With room Service
Call Girls in Gomti Nagar - 7388211116 - With room Service
 
Eni 2024 1Q Results - 24.04.24 business.
Eni 2024 1Q Results - 24.04.24 business.Eni 2024 1Q Results - 24.04.24 business.
Eni 2024 1Q Results - 24.04.24 business.
 
Call Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine ServiceCall Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine Service
 
BEST ✨ Call Girls In Indirapuram Ghaziabad ✔️ 9871031762 ✔️ Escorts Service...
BEST ✨ Call Girls In  Indirapuram Ghaziabad  ✔️ 9871031762 ✔️ Escorts Service...BEST ✨ Call Girls In  Indirapuram Ghaziabad  ✔️ 9871031762 ✔️ Escorts Service...
BEST ✨ Call Girls In Indirapuram Ghaziabad ✔️ 9871031762 ✔️ Escorts Service...
 
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
Keppel Ltd. 1Q 2024 Business Update  Presentation SlidesKeppel Ltd. 1Q 2024 Business Update  Presentation Slides
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
 
Monthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxMonthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptx
 
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130  Available With RoomVIP Kolkata Call Girl Howrah 👉 8250192130  Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Room
 
Grateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdfGrateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdf
 
Regression analysis: Simple Linear Regression Multiple Linear Regression
Regression analysis:  Simple Linear Regression Multiple Linear RegressionRegression analysis:  Simple Linear Regression Multiple Linear Regression
Regression analysis: Simple Linear Regression Multiple Linear Regression
 
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
 
A DAY IN THE LIFE OF A SALESMAN / WOMAN
A DAY IN THE LIFE OF A  SALESMAN / WOMANA DAY IN THE LIFE OF A  SALESMAN / WOMAN
A DAY IN THE LIFE OF A SALESMAN / WOMAN
 
Catalogue ONG NUOC PPR DE NHAT .pdf
Catalogue ONG NUOC PPR DE NHAT      .pdfCatalogue ONG NUOC PPR DE NHAT      .pdf
Catalogue ONG NUOC PPR DE NHAT .pdf
 
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesMysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
 
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service DewasVip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
 
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call GirlsCash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
 

Top 40 Java interview questions

  • 1. java interview Questions Here's some more java questions: 1) Junior java developer a) Basic ocjp (former scjp) questions: – What does static,final mean,purposes; – How many accesibilitymodifiers exist? Please describe them. – Why do you need a main method? – How many constructors can you have? – Define overwriting and overloading – Give java API implementations for overwriting and overloading – Describe the String class – unique properties – StringBuilder vs StringBuffer – Collections :please describe,give some examples and compare them to eachother – ArrayList vs Vector – HashMap vs HashTable – What’s a tree – What’s a map – Multithreading:describe the managementin java – What’s a semaphone? – How many states are there for threads? – Describe the usage for synchronized word (2) – Serialization in java – a descrition and usage – Garbage collection in java – description and usage – Can you guarantee the garbage collection process? b) Simple design pattern questions: – Singleton please describe main features and coding – Factory please describe main features and coding – Have you used others? please describe them 2) Intermediate and Senior level – depending on rate of good responses,additional questions to 1): http://centraladvisor.com/programming-2/java/java-developer-interview Bogdan 08-1-2012 10:34 AM Java interview questions and answers Explain the importance of DriverManager. The basic service to manage setof JDBC drivers. What are the methods in Object? clone,equals,wait,finalize, getClass,hashCode,notify, notifyAll, toString Define a nested class. If all the methods ofa inner class is static then it is a nested class. What is garbage collection? Reclaiming the unused memoryby the invalid objects.Garbage collector is res ponsible for this process
  • 2. Difference betweenLinkedList and ArrayList. LinkedListare meantfor sequential accessing. ArrayList are meantfor random accessing. Define a package. Packages provides wide namespace abilityand allows to group setof classes into a single unit. Raj 12-5-2011 03:10 AM Java interview questions and answers Explain the significance of ListIterator. Using ListIterator you can iterate back and forth. Can you explain inner class. If the methods ofthe inner class can only be accessed via the instance ofthe inner class,then it is called inner class. Can you explain the meaning of aggregation and composition Aggregation - It is a special type of composition.Ifyou expose all the methods ofa composite class and route the method call to the composite method through its reference,then it is called aggregation. Composition - Holding the reference of the other class within some other class is known as composition. Is it possible to instantiate the Math class? You can’tinstantiate the math class. Pankaj 12-5-2011 03:10 AM Java interview questions and answers Define Locale. A Locale objectrepresents a specific geographical,political,or cultural region. How will you load a specific locale? By using ResourceBundle.getBundle(…); Is JVM a compiler or an interpreter? Interpreter
  • 3. Can you explain the usages of Class.forName()? It loads the class into the ClassLoader.It returns the Class.Using thatyou can get the instance ( “class -instance”.newInstance() ). Inq adds a question:Expain the reason for each keyword of public static void main(String args[]) Akash 12-5-2011 03:10 AM Java interview questions and answers Define reflection. Reflection allows programmatic access to information aboutthe fields,methods and constructors ofloaded classes. Can you tell me range of byte? 128 to 127 How to invoke externalprocess in Java. Runtime.getRuntime().exec(….) What is the best way to findout the time/memory consuming process? By using profiler Rakesh 12-5-2011 03:09 AM Java interview questions and answers What is skeleton and stub? Explain their purposes. Stub is a clientside representation ofthe server, which takes care of communicating with the remote server. What kind of thread is the Garbage collector thread? Daemon thread
  • 4. Explain the purpose of Void class. The Void class is an uninstantiable placeholder class to hold a reference to the Class objectrepresenting the primitive Java type void. Nitin 12-5-2011 03:09 AM Java interview questions and answers Explain the importance of finalize method. Finalize method cleans up some resources before itgetgarbage collected. Define mutable object and immutable object. The value of Mutable object is changeable. Ex., StringBuffer The value of an immutable objectcan'tbe changed Ex., String, Integer, Float What are the base class for Error and Exception? Throwable Dharam 12-5-2011 03:09 AM Java interview questions and answers Difference betweenstring and stringbuffer object. String is an immutable object. StringBuffer is a mutable object. Define daemon thread. Daemon thread are the threads which can run withoutuser intervention. The JVM can exit when there are daemon thread by killing them abruptly. Define a DatabaseMetaData. It represents comprehensive information aboutthe database as a whole. Jitu 12-5-2011 03:08 AM Java interview Explain preemptive scheduling and time slicing.
  • 5. In preemptive scheduling,the highestpriority task executes until it enters the waiting or dead states or a higher priority task comes into existence. In time slicing,a task executes for a predefined slice oftime and then reenters the pool of ready tasks. Explain the different scopes for Java variables. 3 scopes ofJava variables are defined below: Instance Initialized to defaultvalues at the time of creation of object, and remain accessible as long as the objectaccessible. Local Defined within a method and remain accessbile onlyduring the course of method excecution and fall out of scope When the method fin execution. Static Static variables are the class level variables. Static variables are initialized when the class is loaded in JVM for the firsttime and remain there as long as the class remains loaded. Static variables are not tied to any particular objectinstance. Akash 11-23-2011 02:26 AM Java interview questions and answers Explain the purpose of finalization. It provides an unreachable objectthe opportunity to perform any cleanup processing before the objectis garbage collected. Explain the importance of daemon thread. Daemon thread is a low priority thread. It runs intermittentlyin the back ground doing the garbage collection operation for the java runtime system. A daemon thread is created using setDaemon method. Synchronized methods and synchronized statements. Synchronized methods Methods that are used to control access to an object. A thread only executes a synchronized method after it has acquired the lock for the method's objector class. Synchronized statements They are similar to synchronized methods. A synchronized statementcan only be executed after a thread has acquired the lock for the object or class referenced in the synchroni
  • 6. statement. Nitin 11-23-2011 01:31 AM Java interview questions and answers What are the way of using thread? Can be implemented byusing runnable interface By inheriting from the Thread class. Difference betweena constructor and a method. Constructor A constructor is a member function ofa class thatis used to create objects ofthat class. It has the same name as the class itself. It has no return type, and is invoked using the new operator. Method A method is an ordinary member function of a class. It has its own name,a return type, and is invoked using the dot operator. Explain how to serialize an object to a file. The class whose instances are to be serialized should implementan interface Serializable,pass the instance to the ObjectOutputStrea which is connected to a fileoutputstream.This will save the objectto a file. Naveen 11-23-2011 01:25 AM Java questions and answers Access Specifiers in Java. Public- public classes,methods,and fields can be accessed from everywhere. Protected- Protected methods and fields can onlybe accessed within the same class,within its subclasses,and within classes ofthe sam e packa Default(no specifier) Such a class,method,or field will be accessible from inside the same package to which the class,method,or field belongs,butnotfrom outside this package. Private Private methods and fields can onlybe accessed within the same class. Private methods and fields are notvisible within subclasses They are not inherited by subclasses.
  • 7. Explain static methods. Static methods are declared with the keyword static as modifier. They are called Static because they affect a class as a whole,not a particular instance ofthe class. They are always invoked without reference to a particular instance ofa class. Restrictions ofusing static methods: It can only call other static methods. It mustonly access static data. It cannotreference to the current objectusing keywords super or this. Priya 11-23-2011 12:55 AM Java interview questions Can you tell me the main Implementations of the Set interface? HashSet TreeSet LinkedHashSet EnumSet Explain the importance of HashSet. It is an unsorted,unordered Set. It uses the hashcode ofthe objectbeing inserted. You can use it when you want a collection with no duplicates and you don’tcare about order when you iterate through it. Explain the importance of TreeSet. It is a setimplementation keeping the elements in sorted order. The elements are sorted according to the natural order of elements or by the comparator provided at creation time. Tina 11-23-2011 12:46 AM Java interview questions and answers Define native method. A native method is implemented in a language other than Java. Explain explicit casting. In Explicit casting,the complier are specificallyinformed abouttransforming the object. Example long a = 890.20; int b = (int) a; //Explicit casting
  • 8. Explain implicit casting. Assigning one entity to another without any transformation guidance to the compiler is implicitcasting. This type of casting is not permitted in all kinds of transformations and maynotwork for all scenarios. Example int a = 6000; long b = a; //Implicitcasting Explain reflection API Reflection is the process ofintrospecting the features and state of a class atruntime and dynamicallymanipulate atrun time. This is supported using Reflection APIwith built-in classes like Class,Method, Fields,Constructors etc. Example:Using Java Reflection API we can get the class name, byusing the getName method. Rajeev 11-22-2011 04:07 AM Java interview questions and answers Explain the importance of Java Virtual Machine (JVM). It converts .java file into .class file by using Compiler and Interpreter reads byte codes. Explain the different types of access modifiers in Java. They determine the type of access to the member ofa class. Types: -Public : accessible to all classes -Protected : accessible to the classes within the same package and anysubclasses. -Private : accessible onlyto the class to which they belong -Default: accessible to the class to which they belong and to subclasses within the same package Why there are no global variables in Java? Global variables are globallyaccessible and hence can create collisions in namespace. What is the Java API? It a large collection of software components thatprovide capabilities,such as graphical user interface (GUI) widgets. Rajeev 11-22-2011 03:48 AM Java interview questions and answers Explain StringTokenizer. It is utility class thatare used to break up string.
  • 9. Example: StringTokenizer str = new StringTokenizer(“Welcome”); while (str.hasMoreTokens()) { System.out.println(st.nextToken()); } Nadeem 11-22-2011 03:42 AM Java interview questions and answers Difference betweenthe boolean & operator and the && operator. When boolean & operator is evaluated, both operands are evaluated && operator is a shortcut operator. When && operator is evaluated, the first operand is evaluated. When firstoperand returns a value of true then the second operand is evaluated. When firstoperand evaluates to false,the evaluation of the second operand is skipped. Nadeem 11-22-2011 03:40 AM Java interview questions Does Java supportpointers? Java doesn'tsupportthe usage ofpointers.Improper handling ofpointers leads to memoryleaks which is whypointer concept hasn't fo place in Java. Swing and Awt AWT are heavy-weight componenets. Swings are light-weightcomponents and this is reason whyswing works faster than AWT. Pass by reference and passbyvalue Pass By Reference is the passing the address itselfrather than passing the value. PassbyValue is passing a copy of the value to be passed. Rakesh S 11-4-2011 01:26 AM Java interview questions Abstract class It mustbe extended or subclassed. It acts as a template. It may contain static data. A class maybe declared abstracteven if it has no abstractmethodsand this prevents itfrom being instantiated.
  • 10. Annie 11-4-2011 01:21 AM Java interview questions and answers - April 18, 2011 What is an abstract method? An abstractmethod is a method which doesn’thave a body, justdeclared with modifier abstract. Explain the use of the finally block. Finally block is a block which always executes. The block executes even when an exception is occurred. The block won't execute only when the user calls System.exit() What is the initial state of a thread? It is in a ready state. What is time slicing? In time slicing,the task continues its execution for a predefined period oftime and reenters the pool of ready tasks. What are Wrapper Classes? Wrapper Classes allow to access primitives as objects. What is List interface? Listis an ordered collection ofobjects. Can you explain transient variables in java? They are the variables thatcannot be serialized. What is synchronization? Synchronization ensures onlyone thread to access a shared resource,thus controls the access ofmultiple threads to shared resources. What is serialization? Serialization helps to convert the state of an object into a byte stream. What is HashMap and Map?
  • 11. Map is Interface and Hashmap is class thatimplements that. Java interview questions and answers - April 20, 2011 What is StringBuffer class? StringBuffer class is same as String class with the exception that it is mutable.It allows change and doesn’tcreate a new instance on change of value. How can you force garbage collection? It is not possible to force GC. We can justrequestitby calling System.gc(). Is it possible an exception to be rethrown? Yes, an exception can be rethrown. What is the return type of a program’s main() method? A program’s main() method has a void return type. Which package is always imported by default? The java.lang package is always imported by default. What is a Class? A class implements the behavior of member objects bydescribing all the attributes of objects and the methods. What is an Object? An objectis the members ofa class.It is the basic unitof a system.It has attributes,behavior and identity. Explain the use of "instanceOf" keyword. "instanceOf"keyword is used to check the type of object. How do you refer to a current instance of object? You can refer the current instance of objectusing "this"keyword. What is the use of JAVAP tool? JAVAP is used to disassemble compiled Java files.This option is useful when original source code is notavailable. In which package is the applet class located?
  • 12. Applet classes are located in "java.applet"package. Java array vs. ArrayList class. ArrayList is a dynamic array that can grow depending on demand whereas Java arrays are fixed length. Explain Enumeration Interface. It defines the methods using which we can enumerate the elements in a collection ofobjects. What are access modifiers? Access modifiers determine ifa method or a data variable can be accessed byanother method in another class. Explain the impact of private constructor. Private constructor prevents a class from being explicitlyinstantiated by callers. What is an exception? An exception is an abnormal condition thatarises in a code sequence atrun time Java interview questions and answers - April 21, 2011 What are ways to create threads? There are two ways to create a thread: extend the java.lang.Thread class implementthe java.lang.Runnable interface How can we stop a thread programmatically? thread.stop; What are daemon threads? Daemon threads are designed to run in background.An example of such thread is garbage collector thread. What are the different types of locks in JDBC? There are four types of major locks in JDBC: Exclusive locks Shared locks Read locks Update locks
  • 13. What are Servlets? Servlets are program that run under web server environments. What are the different ways to maintain state between requests? There are four different ways: URL rewriting Cookies Hidden fields Sessions What are wrapper classes? In Java we have classes for each primitive data types. These classes are called as wrapper class.For e xample, Integer, Character,Double etc. What are checked exceptions? There are exceptions that are forced to catch by Java compiler,e.g IOException. Those exceptions are called checked exceptions. What is the Locale class? Locale class is a class thatconverts the program outputto a particular geographic,political,or cultural region Is main a keyword in Java? No, main is nota keyword in Java. What is the most important feature of Java? Platform independencymakes Java a premium language. What is a JVM? JVM is Java Virtual Machine which is a run time environmentfor the compiled java class files. Does Java support multiple inheritances? No, Java doesn'tsupportmultiple inheritances. What is the base class of all classes? java.lang.Object Can a class be declared as protected?
  • 14. A class can'tbe declared as protected.Only methods can be declared as protected. Can an abstract class be declared final? No, since it is obvious that an abstract class withoutbeing inherited is ofno use. Java interview questions and answers - April 22, 2011 Can we declare a variable as abstract? Variables can't be declared as abstract.Only classes and methods can be declared as abstract. Define Marker Interface. An Interface which doesn'thave any declaration inside butstill enforces a mechanism. What is an abstract method? An abstractmethod is a method whose implementation is deferred to a subclass. When can an object reference be cast to an interface reference? An objectreference is cast to an interface reference when the object implements the referenced interface. Which class is extended by all other classes? The Object class is extended by all other classes. What is the return type of a program's main() method? void. What are the eight primitive Java types? The eightprimitive types are byte, char, short,int, long, float, double,and boolean. Difference between a public and a non-public class. A public class maybe accessed outside ofits package.A non-public class maynotbe accessed outside ofits package. Which Java operator is right associative? The = operator is right associative. What is a transient variable?
  • 15. Transientvariable is a variable that may not be serialized.