Tuesday, June 1, 2010

What is a reflection package?

I have updated in http://www.freejavaclass.com/
java. lang. reflect package has the ability to analyze itself in runtime.

What are inner class and anonymous class?

I have updated in http://www.freejavaclass.com/
Inner class : classes defined in other classes, including those defined in methods are called inner classes. An inner class can have any accessibility including private. Anonymous class : Anonymous class is a class defined inside a method without a name and is instantiated and declared in the same place and cannot have explicit constructors.
Exile on Main Street

What modifiers may be used with top-level class?

I have updated in http://www.freejavaclass.com/

What is the difference between this() and super()?

I have updated in http://www.freejavaclass.com/

this() can be used to invoke a constructor of the same class whereas super() can be used to invoke a super class constructor.

What is Garbage Collection and how to call it explicitly?

I have updated in http://www.freejavaclass.com/

When an object is no longer referred to by any variable, java automatically reclaims memory used by that object. This is known as garbage collection. System. gc() method may be used to call it explicitly.Avatar (Two-Disc Blu-ray/DVD Combo) [Blu-ray]

What is final, finalize() and finally?

I have updated in http://www.freejavaclass.com/

final : final keyword can be used for class, method and variables. A final class cannot be subclassed and it prevents other programmers from subclassing a secure class to invoke insecure methods. A final method can’t be overridden. A final variable can’t change from its initialized value. finalize() : finalize() method is used just before an object is destroyed and can be called just prior to garbage collection. finally : finally, a key word used in exception handling, creates a block of code that will be executed after a try/catch block has completed and before the code following the try/catch block. The finally block will execute whether or not an exception is thrown. For example, if a method opens a file upon exit, then you will not want the code that closes the file to be bypassed by the exception-handling mechanism. This finally keyword is designed to address this contingency.

What are different types of access modifiers?-

I have updated in http://www.freejavaclass.com/

public: Any thing declared as public can be accessed from anywhere. private: Any thing declared as private can’t be seen outside of its class. protected: Any thing declared as protected can be accessed by classes in the same package and subclasses in the other packages. default modifier : Can be accessed only to classes in the same package.

What is the difference between an argument and a parameter?-

I have updated in http://www.freejavaclass.com/

While defining method, variables passed in the method are called parameters. While using those methods, values passed to those variables are called arguments.

What is the use of bin and lib in JDK?

I have updated in http://www.freejavaclass.com/

Bin contains all tools such as javac, appletviewer, awt tool, etc., whereas lib contains API and all packages.

What are Class, Constructor and Primitive data types?

I have updated in http://www.freejavaclass.com/

Class is a template for multiple objects with similar features and it is a blue print for objects. It defines a type of object according to the data the object can hold and the operations the object can perform. Constructor is a special kind of method that determines how an object is initialized when created. Primitive data types are 8 types and they are: byte, short, int, long, float, double, boolean, char.

What is the difference between Assignment and Initialization?

I have updated in http://www.freejavaclass.com/

Assignment can be done as many times as desired whereas initialization can be done only once.

What is the volatile modifier for?

I have updated in http://www.freejavaclass.com/

The volatile modifier is used to identify variables whose values should not be optimized by the Java Virtual Machine, by caching the value for example. The volatile modifier is typically used for variables that may be accessed or modified by numerous independent threads and signifies that the value may change without synchronization.

purpose of java static class

I have updated in http://www.freejavaclass.com/

Static classes are typically used as a convenient way to group related classes without creating a new package.

How can instantiate Java interface without implementing.

public interface Foo { String method(); } public class Claaa {    public static void main(String[] args) {     Foo fooByIC...