Java interview questions and answers

Ask a question
 

700 Java interview questions and answers


Java 1   Java 2   Java 3   Java 4   Java 5   Java 6   Java 7   Java 8   Java 9   Java 10   Java 11   Java 12   Java 13   Java 14   Java 15   Java 16   Java 17   Java 18   Java 19   Java 20   Java 21  Java 22

QUESTION - What is byte code in the context of Java?

-The type of code generated by a Java compiler
-The type of code generated by a Java Virtual Machine
-It is another name for a Java source file
-It is the code written within the instance methods of a class.

View Answer / Hide Answer

ANSWER - The type of code generated by a Java compiler
 

Core Java  interview test (72 questions) new
-By Pradip Patil, Lecturer IIMP MCA

Java  (20 questions) new
-By Pradip Patil, Lecturer IIMP MCA

QUESTION - What is garbage collection in the context of Java?

-The operating system periodically deletes all of the java files available on the system.
-Any package imported in a program and not used is automatically deleted.
-When all references to an object are gone, the memory used by the object is automatically reclaimed.
-The JVM checks the output of any Java program and deletes anything that doesn't make sense.

View Answer / Hide Answer

ANSWER - When all references to an object are gone, the memory used by the object is automatically reclaimed.

QUESTION - What is different between a Java applet and a Java application?

-An application can in general be trusted whereas an applet can't.
-An applet must be executed in a browser environment.
-An applet is not able to access the files of the computer it runs on
-All of the above

View Answer / Hide Answer

ANSWER - All of the above

QUESTION - You read the following statement in a Java program that compiles and executes.

submarine.dive(depth);

What can you say for sure?

-depth must be an int
-dive must be a method.
-dive must be the name of an instance field.
-submarine must be the name of a class

View Answer / Hide Answer

ANSWER - dive must be a method.

QUESTION - Which is true about an anonymous inner class?

-It can extend exactly one class and implement exactly one interface.
-It can extend exactly one class and can implement multiple interfaces.
-It can implement multiple interfaces regardless of whether it also extends a class.

View Answer / Hide Answer

ANSWER - It can extend exactly one class and can implement multiple interfaces.

QUESTION - If a thread is to be declared as a daemon thread, it must be declared before

-start method
-run method
-stop method
-none

View Answer / Hide Answer

ANSWER - start method

QUESTION - Under what circumstances might you use the yield method of the Thread class

-To call from the currently running thread to allow another thread of the same or higher priority to run
-To call on a waiting thread to allow it to run
-To allow a thread of higher priority to run
-To call from the currently running thread with a parameter designating which thread should be allowed to run

View Answer / Hide Answer

ANSWER - To call from the currently running thread to allow another thread of the same or higher priority to run

QUESTION - Which of the following is the correct syntax for suggesting that the JVM performs garbage collection

-System.free();
-System.setGarbageCollection();
-) System.out.gc();
-System.gc();

View Answer / Hide Answer

ANSWER - System.gc();

QUESTION - When method defined in subclass which has same signature as a method in a super class, it is known as method ________________

-Overloading
-Overriding
-Packing
-none of these

View Answer / Hide Answer

ANSWER - Overriding

QUESTION - In an AWT or Swing container, BoxLayout places the components in which form?
1) left to right
2) top to bottom
3)right to left
4)bottom to top

-1
-2
-1 and 2
-3 and 4

View Answer / Hide Answer

ANSWER - 1 and 2

QUESTION - A class that cannot be a subclass is called as______ class.

-abstract
-parent class
-Final
-none of these

View Answer / Hide Answer

ANSWER - Final

QUESTION - Which model used in swing component?

-Model view controller
-Event delegation model
-Document object model
-network model

View Answer / Hide Answer

ANSWER - Model view controller

QUESTION - When several threads act on object simultaneously and the result is reliable then it is known as ____________

-Boxing
-Unsynchronized
-synchronized
-none of these

View Answer / Hide Answer

ANSWER - synchronized

QUESTION - All collection classes in java.util package are implementation classes of different interfaces

-True
-False

View Answer / Hide Answer

ANSWER - True

QUESTION - DeflaterOutputStrem and InflaterInputStream classes are available in which package?

-java.io
-java.util
-java.io.zip
-java.util.zip

View Answer / Hide Answer

ANSWER - java.util.zip

QUESTION - Process of storing the object contain into the file is known as ______________

-synchronization
-serialization
-zip
-doping

View Answer / Hide Answer

ANSWER - serialization

QUESTION - Static and transient variable cannot be serialized

-Yes
-No

View Answer / Hide Answer

ANSWER - Yes

QUESTION - All components from javax.swing are developed in ______________

-C++
-C
-pascal
-pure java

View Answer / Hide Answer

ANSWER - pure java

QUESTION - FileOutputStream class store the data in the form of _________

-character
-file
-bytes
-bit

View Answer / Hide Answer

ANSWER - bytes

QUESTION - What is the default buffer size used by any buffered class?

-128 bytes
-256 bytes
-512 bytes
-1024 bytes

View Answer / Hide Answer

ANSWER - 512 bytes

Download Java interview questions and answers pdf 

Explain the difference between Java and JavaScript.
Explain how to obtain a performance profile of my Java Program.
Explain the purpose of the executable files that have an extra _g at the end of their names, e.g. java_g.
If Java is platform independent, why doesn't it run on all platforms?
Explain how to access native operating system calls from my Java program.
How do we create and use sockets in Java?
Explain how to send data from my Java program to a CGI program.
Explain the difference between a URL instance and a URLConnection instance.
How do I read a line of input at a time in Java?
Why is thread synchronization important for multithreaded programs?
Explain how to create a thread and start it running.
When should we use an event adapter class?
Explain the component and container classes.
What is the difference between a runtime exception and a plain exception?
Can you explain in brief life cycle for stateless and stateful beans?
What is Passivation and Activation in EJB?
How do we implement caching in JSP?
Explain the different Authentication options available in Servlets.
How can we use beans in JSP?
Explain the difference between JavaBeans and taglib directives.
Explain the different scopes an object can have in a JSP page.
Explain the use of Externalization interface.
Explain widening conversion and Narrowing conversion.
How do we implement deep cloning?  

Java interview questions and answers for freshers and experienced

Java features

Simple, Object-Oriented, Robust, Distributed, Portable, Interpreted, Multithreaded, Platform Independent, Secure...........
Read answer

Java program execution

What is JVM? Explain its roles and functions.
Explain why Java is called as Platform independent language. Explain how Java executable executes on any platform where JVM is available...................
Read answer

Java architecture

Java programming language, Java class file format, Java Application Programming Interface, Java virtual machine.............
Read answer

Java class

Explain the features of Java class. Explain Fields, Methods, and Access Levels.
What are accessors and mutator methods in a Java class? Explain with example for each.
Explain the importance of 'this' reference. Write a code to depicts the use of 'this' reference
Explain static variables and static methods in Java. Provide an example to explain them..................
Read answer

Java constructors

What is a constructor? Explain the differences between methods and constructor.
Differences between constructors and methods.
Write code to depict the use of constructor.....................
Read answer

Java class member

What is instance members? Explain with an example
What is instance variable? Explain with an example
What is instance method? Explain with an example
What is static member? Explain with an example
What is static variable? Explain with an example......................
Read answer

Java packages

What are Java packages? Explain the importance of Java packages.
Steps for creating a package in Java
Explain the packages access specifier, i.e. private, protected, public, default.............
Read answer

Java garbage collector

Explain Java Garbage collector. Why garbage collection? Brief explanation of Garbage collection algorithms.
Explain the importance of finalizers in Java. Write code to depict the uses of finalizers in Java...............
Read answer

Java super keyword

Explain the importance of 'super' keyword in Java. Write code to depict the uses of 'super' keyword - The keyword ‘super’ is used for referring parent class instance....................
Read answer

Java overloading & overriding

Define Method overloading. Explain its uses. Provide a code sample to explain the uses of Method overloading
Define Method overriding. Explain its uses. Provide a code sample to explain the uses of Method overloading
Difference between overloading and overriding.......................
Read answer

Java string class

Describe Java string class. Explain methods of Java string class. Explain the characteristics of StringBuffer class - String Class: The String class is immutable, The contents of the String object can not be changed, String class is final class. That implies it can not have sub classes......................
Read answer

Java inner classes

What is Java inner class? Explain the types of inner classes, i.e. Static member classes, Member classes, Local classes, Anonymous classes
Need of inner class in context with adapter classes
Explain few Wrapper Classes Methods...............
Read answer

Java reflection class

Explain about Java reflection class.
Write a code sample to depict the uses of Java reflection class.........
Read answer

Java swing

What is Swing? Explain the need of Swing.
Write some important features of Swing.
Describe Java Swing class hierarchy.
Explain the need of Layout manager...........
Read answer

Java layout manager

Explain different layout manager in Java. - A layout manager organizes the objects in a container, Different layouts are used to organize or to arrange objects.............
Read answer

Java exception handling

Explain the need of Exception handling.
Explain the Exceptions categories, i.e. checked and unchecked exceptions.
Provide the general form of Exception handling constructs with explanation
What is user defined Exception? Explain with an example............
Read answer

Java multithreading

What is Multithreading? Explain the life cycle of a thread.
Explain how to use thread class for Multithreading in Java. Explain with an example.
What is Runnable interface? Explain how to use Runnable interface for Multithreading.
What are the methods of thread class in java? Explain them
Can your explain thread priorities?..............
Read answer

Java file handling

Explain the use of Streams.
Difference between Stream classes and Reader writer classes
Explain and demonstrate the use of File, RandomAccessFile classes.
Explain the use of Reader and Writer classes..............
Read answer

Java utility classes

What is object Serialization? Explain the use of Persisting object.
Depict the step of using object Deserialization.....................
Read answer

Java socket programming

What is socket? Explain the features of socket.
Explain the characteristics of Java socket class.
Explain ServerSocket class with an example
Explain InetAddress class with an example
Explain DatagramSocket class with an example
Explain DatagramPacket class with an example.............
Read answer

JDBC

Purposes of JDBC API
Describe 4 types of JDBC drivers and their characteristics with usages.
State the functionalities of important classes in JDBC packages.
Explain how to use JDBC statement to execute SQL queries. Show in an example
Explain how to use Prepared Statement to execute parameterized queries. Show in an example
What is JDBC Callable Statement?
What is batch updates in JDBC? Explain with an example......................
Read answer

Write your comment - Share Knowledge and Experience

Discussion Board
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 accesibility modifiers 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 management in 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 set of 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 of a inner class is static then it is a nested class.

What is garbage collection?

Reclaiming the unused memory by the invalid objects. Garbage collector is responsible for this process


Difference between LinkedList and ArrayList.

LinkedList are meant for sequential accessing.

ArrayList are meant for random accessing.


Define a package.

Packages provides wide namespace ability and allows to group set of 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 of the inner class can only be accessed via the instance of the 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. If you expose all the methods of a 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’t instantiate the math class.


Pankaj 12-5-2011 03:10 AM

Java interview questions and answers

Define Locale.

A Locale object represents 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 that you 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 about the fields, methods and constructors of loaded classes.


Can you tell me range of byte?

128 to 127


How to invoke external process 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 client side representation of the 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 object representing 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 it get garbage collected.

Define mutable object and immutable object.

The value of Mutable object is changeable.
Ex., StringBuffer

The value of an immutable object can't be 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 between string and stringbuffer object.

String is an immutable object.

StringBuffer is a mutable object.


Define daemon thread.

Daemon thread are the threads which can run without user intervention.
The JVM can exit when there are daemon thread by killing them abruptly.


Define a DatabaseMetaData.

It represents comprehensive information about the database as a whole.


Jitu 12-5-2011 03:08 AM

Java interview

Explain preemptive scheduling and time slicing.

In preemptive scheduling, the highest priority 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 of time and then reenters the pool of ready tasks.


Explain the different scopes for Java variables.

3 scopes of Java variables are defined below:


Instance

Initialized to default values at the time of creation of object, and remain accessible as long as the object accessible.

Local

Defined within a method and remain accessbile only during the course of method excecution and fall out of scope When the method finishes

execution.

Static

Static variables are the class level variables.
Static variables are initialized when the class is loaded in JVM for the first time and remain there as long as the class remains loaded.
Static variables are not tied to any particular object instance.

Akash 11-23-2011 02:26 AM

Java interview questions and answers

Explain the purpose of finalization.

It provides an unreachable object the opportunity to perform any cleanup processing before the object is garbage collected.

Explain the importance of daemon thread.

Daemon thread is a low priority thread.
It runs intermittently in 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 object or class.

Synchronized statements

They are similar to synchronized methods.
A synchronized statement can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement.


Nitin 11-23-2011 01:31 AM

Java interview questions and answers

What are the way of using thread?

Can be implemented by using runnable interface
By inheriting from the Thread class.

Difference between a constructor and a method.

Constructor

A constructor is a member function of a class that is used to create objects of that 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 implement an interface Serializable, pass the instance to the ObjectOutputStream which is connected to a fileoutputstream. This will save the object to 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 only be accessed within the same class, within its subclasses, and within classes of the same package.

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, but not from outside this package.

Private

Private methods and fields can only be accessed within the same class.
Private methods and fields are not visible 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 of the class.
They are always invoked without reference to a particular instance of a class.

Restrictions of using static methods:

It can only call other static methods.
It must only access static data.
It cannot reference to the current object using 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 of the object being inserted.
You can use it when you want a collection with no duplicates and you don’t care about order when you iterate through it.

Explain the importance of TreeSet.

It is a set implementation 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 specifically informed about transforming 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 implicit casting.
This type of casting is not permitted in all kinds of transformations and may not work for all scenarios.

Example

int a = 6000;

long b = a; //Implicit casting


Explain reflection API

Reflection is the process of introspecting the features and state of a class at runtime and dynamically manipulate at run time.
This is supported using Reflection API with built-in classes like Class, Method, Fields, Constructors etc.

Example: Using Java Reflection API we can get the class name, by using 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 of a class.

Types:

-Public : accessible to all classes
-Protected : accessible to the classes within the same package and any subclasses.
-Private : accessible only to 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 globally accessible and hence can create collisions in namespace.


What is the Java API?

It a large collection of software components that provide 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 that are 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 between the boolean & operator and the && operator.

When boolean & operator is evaluated, both operands are evaluated
&& operator is a short cut operator.

When && operator is evaluated, the first operand is evaluated.
When first operand returns a value of true then the second operand is evaluated.
When first operand evaluates to false, the evaluation of the second operand is skipped.

Nadeem 11-22-2011 03:40 AM

Java interview questions

Does Java support pointers?

Java doesn't support the usage of pointers. Improper handling of pointers leads to memory leaks which is why pointer concept hasn't found place in Java.

Swing and Awt

AWT are heavy-weight componenets.
Swings are light-weight components and this is reason why swing works faster than AWT.


Pass by reference and passby value

Pass By Reference is the passing the address itself rather than passing the value.
Passby Value is passing a copy of the value to be passed.

Rakesh S 11-4-2011 01:26 AM

Java interview questions

Abstract class

It must be extended or subclassed.
It acts as a template.
It may contain static data.
A class may be declared abstract even if it has no abstract methodsand this prevents it from being instantiated.

Annie 11-4-2011 01:21 AM

 

Java interview questions and answers - April 18, 2011

What is an abstract method?

An abstract method is a method which doesn’t have a body, just declared 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 of time and reenters the pool of ready tasks.

What are Wrapper Classes?

Wrapper Classes allow to access primitives as objects.

What is List interface?

List is an ordered collection of objects.

Can you explain transient variables in java?

They are the variables that cannot be serialized.

What is synchronization?

Synchronization ensures only one thread to access a shared resource, thus controls the access of multiple 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 that implements 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’t create a new instance on change of value.

How can you force garbage collection?

It is not possible to force GC. We can just request it by 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 by describing all the attributes of objects and the methods.

What is an Object?

An object is the members of a class. It is the basic unit of 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 object using "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 not available.

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 of objects.

What are access modifiers?

Access modifiers determine if a method or a data variable can be accessed by another method in another class.

Explain the impact of private constructor.

Private constructor prevents a class from being explicitly instantiated by callers.

What is an exception?

An exception is an abnormal condition that arises in a code sequence at run 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
implement the 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 example, 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 that converts the program output to a particular geographic, political, or cultural region

Is main a keyword in Java?

No, main is not a keyword in Java.

What is the most important feature of Java?

Platform independency makes Java a premium language.

What is a JVM?

JVM is Java Virtual Machine which is a run time environment for the compiled java class files.

Does Java support multiple inheritances?

No, Java doesn't support multiple inheritances.

What is the base class of all classes?

java.lang.Object

Can a class be declared as protected?

A class can't be 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 without being inherited is of no 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't have any declaration inside but still enforces a mechanism.

What is an abstract method?

An abstract method is a method whose implementation is deferred to a subclass.

When can an object reference be cast to an interface reference?

An object reference 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 eight primitive types are byte, char, short, int, long, float, double, and boolean.

Difference between a public and a non-public class.

A public class may be accessed outside of its package. A non-public class may not be accessed outside of its package.

Which Java operator is right associative?

The = operator is right associative.

What is a transient variable?

Transient variable is a variable that may not be serialized. 

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15   

 
Interview questions
Home | Want a Job? Submit Key Skills | My key skills | About us | Sitemap | Contact us