Академический Документы
Профессиональный Документы
Культура Документы
Reclaiming the unused memory by the invalid objects. Garbage collector is responsible for this
process
Define a package.
Packages provides wide namespace ability and allows to group set of classes into a single unit.
If the methods of the inner class can only be accessed via the instance of the inner class, then it
is called inner class.
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
Composition - Holding the reference of the other class within some other class is known as
composition.
Define Locale.
By using ResourceBundle.getBundle(…);
Interpreter
It loads the class into the ClassLoader. It returns the Class. Using that you can get the instance
( “class-instance”.newInstance() ).
Define reflection.
Reflection allows programmatic access to information about the fields, methods and
constructors of loaded classes.
128 to 127
Runtime.getRuntime().exec(….)
By using profiler
Stub is a client side representation of the server, which takes care of communicating with the
remote server.
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.
Throwable
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.
Java interview
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.
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
It provides an unreachable object the opportunity to perform any cleanup processing before the
object is garbage collected.
Synchronized methods
Synchronized statements
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
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.
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.
HashSet
TreeSet
LinkedHashSet
EnumSet
In Explicit casting, the complier are specifically informed about transforming the object.
Example
long a = 890.20;
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;
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.
It converts .java file into .class file by using Compiler and Interpreter reads byte codes.
Types:
Global variables are globally accessible and hence can create collisions in namespace.
It a large collection of software components that provide capabilities, such as graphical user
interface (GUI) widgets.
Explain StringTokenizer.
Example:
while (str.hasMoreTokens()) {
System.out.println(st.nextToken());
Difference between the boolean & operator and the && operator.
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.
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.
Abstract class
An abstract method is a method which doesn’t have a body, just declared with modifier abstract.
It is in a ready state.
In time slicing, the task continues its execution for a predefined period of time and reenters the
pool of ready tasks.
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?
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.
You can refer the current instance of object using "this" keyword.
JAVAP is used to disassemble compiled Java files. This option is useful when original source
code is not available.
ArrayList is a dynamic array that can grow depending on demand whereas Java arrays are fixed
length.
It defines the methods using which we can enumerate the elements in a collection of objects.
Access modifiers determine if a method or a data variable can be accessed by another method in
another class.
What is an exception?
thread.stop;
Daemon threads are designed to run in background. An example of such thread is garbage
collector thread.
Exclusive locks
Shared locks
Read locks
Update locks
URL rewriting
Cookies
Hidden fields
Sessions
In Java we have classes for each primitive data types. These classes are called as wrapper class.
For example, Integer, Character, Double etc.
There are exceptions that are forced to catch by Java compiler, e.g IOException. Those
exceptions are called checked exceptions.
Locale class is a class that converts the program output to a particular geographic, political, or
cultural region
What is a JVM?
JVM is Java Virtual Machine which is a run time environment for the compiled java class files.
java.lang.Object
No, since it is obvious that an abstract class without being inherited is of no use.
Variables can't be declared as abstract. Only classes and methods can be declared as abstract.
An Interface which doesn't have any declaration inside but still enforces a mechanism.
An object reference is cast to an interface reference when the object implements the referenced
interface.
The eight primitive types are byte, char, short, int, long, float, double, and boolean.
A public class may be accessed outside of its package. A non-public class may not be accessed
outside of its package.