Java Interview Questions
Java Interview Questions
Can a method be overloaded based on different return type but same argument type ?
No, because the methods can be called without using their return type in which case there is ambiquity for thecompiler.
What happens to a static var that is defined within a method of a class ?
Can’t do it. You’ll get a compilation error.
How many static init can you have ?
As many as you want, but the static initializers and class variable initializers are executed in textual order and maynot refer to class variables declared in the class whose declarations appear textually after the use, even though these class variables are in scope
Describe the Garbage Collection process in Java ?
The JVM spec mandates automatic garbage collection outside of the programmers control. The System.gc() or Runtime.gc()is merely a suggestion to the JVM to run the
GC process but is NOT guaranteed.
How do you ensure size of a primitive data type ?
What is the difference amongst JVM Spec, JVM Implementation, JVM Runtime ?
The JVM spec is the blueprint for the JVM generated and owned by Sun. The JVM implementation is the actualimplementation of the spec by a vendor and the JVM.Runtime is the actual running instance of a JVM implementation.
Can RMI and Corba based applications interact ?
Yes they can. RMI is available with IIOP as the transport protocol instead of JRMP
What is the diffrence between an Abstract class and Interface ?
Interface defines the methods. There is no implementation.
Whereas Abstract class may have few implemented methods.If some common functionality needs to be shared.
What do you know about the garbage collector ?
Java has an inbuilt mechanisim for garbage collection.
All those objects not longer being referenced are garbage collected.i.e the memory used by these objects isreleased.
What is the use of Servlets ?
To generate dynamic content based on the request.
What is JDBC? How do you connect to the Database ?
Java Database connectivity.
Using jdbc drivers provided by db drivers.
What is the difference between RMI & Corba ?
Remote method invocation : java only. uses JRMP to communication between java objects
Common object request broker architecture : platform independent. Uses IIOP to communicate between objects.
What is JAR file ?
Jar file is an archive of java classes.
What are 4 drivers available in JDBC ?
Type 4 : pure java driver. no need to have db client installed on client mcs.
What is serialization ?
Process of persisting an object.
How to call EJB from Struts?
We can call EJB from struts by using the service locator design patteren or by Using initial context with create homeobject and getting return remote referenc object.
What are the four corner stones of OOP ?
Abstraction, Encapsulation, Polymorphism and Inheritance.
What is Downcasting ?
Downcasting is the casting from a general to a more specific type, i.e. casting down the hierarchy.
What is the restriction on an Overridden methods accessibility ?
Overriding methods cannot reduce accessibility – they can either have same or greater accessibility.
What is a “stateless” protocol ?
Without getting into lengthy debates, it is generally accepted that protocols like HTTP are stateless i.e. there is noretention of state between a transaction which is a single request response combination.
- New to Java – Getting started tutorial
- Creating programs – Java Tutorial
- Methods and classes – Java Tutorial
- Blocks and overloading – Java Tutorial
- Input, Selection and Repetition
- How to create arrays and strings – Java tutorial
- Advanced array techniques – Java tutorial
- Creating applets – Java Tutorial
- Inheritance and class extensions – Java Tutorial
- Super classes and subclasses – Java Tutorial
- Abstract Class – Java Tutorial
- Introduction to Exception Handlers – Java tutorial
- Input and Output – Java tutorial
- New to Java – Introductory guide for beginners
- Getting started with Java
- Building Java 7 on Mac OS X
- What and How of java
- Java Interview Questions
- Java Aspects
- Java Enums
- Java Generics
- Java Annotations
- Autoboxing in Java
- Ten things a Java developer should know
- Java 8 Overview
- Default Methods in Java 8
- Lambda Expressions in Java 8
- Parallel Operations in Java 8
- Date and Time API in Java 8
- Top 5 Java Books for beginners