1) What are the differences between the == operator and the equals() method?
Well, first off, == is a fundamental operator in the language. The result type of the expression is a boolean. For comparing boolean types, it compares the operands for the same truth value. For comparing reference types, it compares the operands for the same reference value (i.e., refer to the same object or are both null). For numeric types, it compares the operands for the same integer value or equivalent floating point values.
In contrast, equals() is an instance method which is fundamentally defined by the java.lang.Object class. This method, by convention, indicates whether the receiver object is "equal to" the passed in object. The base implementation of this method in the Object class checks for reference equality. Other classes, including those you write, may override this method to perform more specialized equivalence testing.
2) How can I force garbage collection to take place?

Strictly, you can't force it.
You can, however, call System.gc(), which is a "hint" to the runtime engine that now might be a good time to run the GC. Some implementations take that hint to heart and some don't.
3) When should I use an interface instead of an abstract class?

There are two primary axes of "inheritance" in object-oriented languages like Java. "Implementation" inheritance is where the sub-class inherits the actual code implementation from the parent. "Interface" inheritance is where the "sub-class" adheres to the public interface of the "parent".
Alas, Java actually mixes the two notions together a bit... Java interfaces are nice and clean -- when you "implement" an interface, you are stipulating that your class adheres to the "contract" of the interface that you specified. Java class inheritance isn't so clean -- when you sub-class in Java you are getting both the code inheritance but you are also stipulating that your sub-class adheres to the "contract" of the interface of the parent class.
Abstract classes in Java are just like regular Java classes but with the added constraint that you cannot instantiate them directly. In terms of that added constraint, they are basically classes which don't actually implement all of the code specified by their "contract".
So, it's generally considered good OO practice to specify the "contract" which you want to adhere to via Java interfaces. Then use normal Java class inheritance primarily for code reuse purposes. Use abstract Java classes when you want to provide some standard base code but want/need to force the user's of your class to complete the implementation (i.e., you create a skeleton implementation and the sub-classes must flesh it out).
4) What are the differences between instance and class variables?

Instance variables have separate values for each instance of a class. Class variables maintain a single shared value for all instances of the class, even if no instance object of that class exists.
You would use the static keyword to change an instance variable into a class variable.
Both instance and class variables are declared at the class level, not within methods:
public class Foo {
static private int count; // class variable
String name; // instance variable
private void Bar() {
int halfCount; // local variable
Note also that classes are loaded by classloaders therefore class variables are unique on a per-classloader basis.
5) What is an overloaded method?

Overloaded methods are multiple methods in the same class that share the same name but have different parameter lists. Overloaded methods cannot have the same parameter lists with different return types.
6) What is a final class?

When you declare a class to be final, it can never be subclassed. This is usually done for security or performance reasons.
public final class Math {
// ...
7) What is a final method?

When you declare a method to be final, it can never be overridden in subclasses. This is usually done for security or performance reasons, providing additional information to the JIT compiler or HotSpot. One word of caution -- making methods final restricts later design decisions.
8) Why do I not have to import the classes in the java.lang package?

The classes in the java.lang package are so important that the compiler implicitly imports all the classes there. This ensures classes in the unnamed package are not accidently used instead of the key classes and interfaces.
9) Can I override a method that doesn't throw exceptions with one that does?

Overriding methods cannot change the signature of the overridden method. All exceptions are included in the signature of the method except for RunTimeException and it's subclasses. So, the only exceptions you may add to an overriding method must be a (sub-class of) RunTimeException.
10) Can I restart a stopped thread?

In short, no. Once a thread is stopped, it cannot be restarted. Keep in mind though that the use of the stop() method of Thread is deprecated and should be avoided.
11) How do I have one thread wait for another thread to finish before continuing?

You can wait for a thread to finish by calling its join() method. For instance, in the following code, the current thread will wait until thread2 finishes before printing Done.
// do more stuff here
12) What is a method's signature?

The signature of a method is the combination of the method's name along with the number and types of the parameters (and their order).
13) Why does "float f = 3.5;" generate a compile-time error?

The constant value 3.5 is recognized by the compiler to be a double rather than a float. You must place an f after the 3.5 for it to be recognized as a floating point constant value:
float f = 3.5f;

14) What is the difference between the & and && operators?

It depends on the type of the arguments...
For integer arguments, the single ampersand ("&")is the "bit-wise AND" operator. The double ampersand ("&&") is not defined for anything but two boolean arguments.
For boolean arguments, the single ampersand constitutes the (unconditional) "logical AND" operator while the double ampersand ("&&") is the "conditional logical AND" operator. That is to say that the single ampersand always evaluates both arguments whereas the double ampersand will only evaluate the second argument if the first argument is true.
For all other argument types and combinations, a compile-time error should occur.

15) How can I cast an Object reference to an array reference?

Pretty much just like any other cast:
MyArrayRef = (MyArrayType []) objectRef;
16) How is Java's "byte code" different from other codes (like source code, native code, etc.)?

Java's byte code is what the typical Java compilers create in the .class files. It is a binary language that is defined for the Java Virtual Machine (JVM). The JVM is the abstract machine which runs the byte codes (analogously to how an Intel 80386 runs .obj files).
17) Can an anonymous class have static members?

With one exception, anonymous classes cannot contain static fields, methods, or classes. The only static things they can contain are static final constants.
18) When I create anonymous classes, what access modifier do they get?

Anonymous classes get the default, unnamed access modifier. You cannot make them private, protected, public, or static.
19) How do I create a constructor for an anonymous class?

Since anonymous classes don't have names, you cannot create a constructor by just using the name of the class. What you can do instead is to use an "instance initializer". Instance initializers basically look like methods with no names or return values:
ActionListener listener = new ActionListener {
System.out.println("Instance Initializer");
public void actionPerformed(ActionEvent event) {
20) When should I use a "private" constructor?
The most common use that I see for private (and protected) constructors is in implementing singletons and some types of object factories. Basically, you use a static method to manage the creation of one (or more) instances of the class.
21) I'm trying to use an AWT List and the List collection in my program. How do I overcome the class name conflict?

In such a case of name conflict:
If you need only one definition but your type-import-on-demand (using import xxx.yyy.*;) causes the conflict, use explicit import for the reference you need.
import java.awt.*;
import java.util.List; // if you need this List in your program.
If you need both in the same Java file, you will have to explicitly refer at least one.
import java.awt.*;
import java.util.List; // your can use "List" for this one.
java.awt.List myAwtList = new java.awt.List();

List myUtilList = new List();
For clarity, I would suggest to explicitly manage both in that case.
22) How can I do a deep clone of an object?

The default/conventional behavior of clone() is to do a shallow copy. You can either override clone() to do a deep copy or provide a separate method to do a deep clone.
The simplest approach to deep cloning is to use Java serialization, where you serialize and deserialize the object and return the deserialized version. This will be a deep copy/clone, assuming everything in the tree is serializable. If everything is not serializable, you'll have to implement the deep cloning behavior yourself.
Assuming everything is serializable, the following should create a complete deep copy of the current class instance:
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
Object deepCopy = ois.readObject();
23) What are the differences between the built-in, primitive types (like int) and the equivalent, non-primitive object-wrapper classes (like Integer)?

The elemental types (int, long etc.) are fundamental parts of the Java language - they're reserved words. They directly represent a quantity, a character, etc.
The java.lang classes (e.g. Void, Integer, Long etc.) serve two functions - first, they provide utility methods (generally static to those classes) for doing commonplace tasks like turning an integer into a String and vice versa.
The second use for the java.lang classes is as a wrapper for the elemental types - this is needed because Java represents all collections (other than arrays) in terms of java.lang.Object - so e.g., a Vector can only contain objects, not elemental types. If you wanted a Vector or Hashtable of ints, you'd have to wrap each int in a java.lang.Integer, and then unwrap the int when you retrieved values from the collection.
Equally, if you wanted to define a method that returned either a String or an int, you would define the function as returning a java.lang.Object; and then in practice you'd return either a java.lang.String or a java.lang.Integer, as appropriate.
24) In the main method of a class (or any static method), how can I find out what class I am in?

To get the Class object associated with that class, you have to reference the name of the class directly and use the .class keyword. I.e., if your class is named Foo use Foo.class to get the Class object for Foo.
25) How do I get a list of the files in a .zip file from Java?

You can get a java.util.Enumeration of objects by using the method.
26) What is a JIT compiler?

A Just-In-Time compiler is one way to implement the Java Virtual Machine. Rather than the typical, pure interpreter, a JIT compiler will, on demand, compile the platform independent Java byte codes into platform specific executable code, in real-time. The first time through, the byte codes are compiled before being executed. Future passes will use a cached version of the compiled code. This tends to result in a performance increase of 10-100 times, depending upon the task at hand, over purely interpreted byte codes.
27) What's a .jar file?

A JAR file or Java ARchive is a way of bundling multiple files together as a single file. Like a ZIP file, they support compression and retain the directory structure of the files. They can be used for delivering things like JavaBeans and Applets, and usually include support files like image and sound files, in addition to the actual Java classes. In addition, they can be digitally signed so a user can grant privileges to allow the software to perform operations not normally permitted from untrusted software.
To create a JAR file, use the jar tool that comes with the JDK.
28) What are the differences between casting to String, using the toString() method, and using the String.valueOf() method?

Casting only transforms the reference to the object from one type to another. Casting does nothing to the underlying object itself. The compiler and/or the runtime engine will verify the fact that the reference that you're casting to a reference to a String is, in fact, referring to an object which is (type compatible with) a String.
The String.value() method allows for the creation of a String representation of the built-in, primitive data types such as int, boolean, float, etc.
The .toString() method is a method which all Java classes inherit from the java.lang.Object root class (and which many classes override). The .toString() method of each class is supposed to create an appropriate String representation of objects of that class.
29) What is the difference between a Java compiler and a Java interpreter?

Typically, when used in that generic manner, the term Java compiler refers to a program which translates Java language source code into the Java Virtual Machine (JVM) bytecodes. The term Java interpreter refers to a program which implements the JVM specification and actually executes the bytecodes (and thereby running your program).
30) Why are the methods wait() and notify() defined in the Object class when they are used with Threads?

The wait() and notify() methods are object-specific. The wait() method suspends the current thread of execution, and tells the object to keep track of the suspended thread. The notify() method tells the object to wake up the suspended threads that it is currently keeping track of. Since wait() and notify() are object specific, they must be used within code that is synchronized on the object in question.
It is also important to use state variables when using wait() and notify(), as threads can be woken up by conditions other than notify().
suspend() is similar to wait() but does not add the thread to an object's wait list.
31) How to run a batch file/native application from Java?

Use Runtime.exec(String pathToBatchFile).
32) What are the differences between "JVM" and "JRE"?

Technically, the term "JVM" specifies the Java Virtual Machine. I.e., the "JVM" is the definition of the abstract, stack-based computational engine used to execute Java bytecodes. The term "JRE" stands for the Java Runtime Environment (if you follow Sun's nomeclature) or, interchangeably, Java Runtime Engine. I.e., a JRE is a specific implementation of the the JVM, including the core libaries.
Alas, in practice, many people use "JVM" for both cases. So, be careful to understand the context that people are talking about when using the term "JVM" to distinguish between the abstract definition and a specific implementation.
33) What's the difference between "JDK" and "JRE"?

The "JDK" is the Java Development Kit. I.e., the JDK is bundle of software that you can use to develop Java based software. The "JRE" is the Java Runtime Environment. I.e., the JRE is an implementation of the Java Virtual Machine which actually executes Java programs.
Typically, each JDK contains one (or more) JRE's along with the various development tools like the Java source compilers, bundling and deployment tools, debuggers, development libraries, etc.
34) What are the differences between checked and unchecked exceptions?

A checked exception is any subclass of Exception (or Exception itself), excluding class RuntimeException and its subclasses.
Making an exception checked forces client programmers to deal with the possibility that the exception will be thrown. eg, IOException thrown by's read() method
Unchecked exceptions are RuntimeException and any of its subclasses. Class Error and its subclasses also are unchecked.
With an unchecked exception, however, the compiler doesn't force client programmers either to catch the exception or declare it in a throws clause. In fact, client programmers may not even know that the exception could be thrown. eg, StringIndexOutOfBoundsException thrown by String's charAt() method.
Checked exceptions must be caught at compile time. Runtime exceptions do not need to be. Errors often cannot be, as they tend to be unrecoverable.
35) What are mutable and immutable objects in Java?

As per the dictionary, mutable objects are objects which can change their values and immutable objects are objects which cannot have their values changed.
36) Is it possible to start an application (from command line) from a method other than main?

No, it is not possible to start an application from a method other than main, as the runtime system will look for a method i.e., public static void main. If the method is not found we get an error by name java.lang.NoSuchMethodError.
37) Why can't I declare a static method in an interface?

Because all methods declared in an interface are (implicitly) also "abstract" methods since, by definition, they do not define the (implementation of) the method.
38) What's the difference between JavaScript and Java?

JavaScript is an object-oriented scripting language that allows you to create dynamic HTML pages, allowing you to process/validate input data and maintain data, usually within the browser. Originally created by Netscape for use with their Navigator browser, Microsoft reverse engineered the technology, added their own varients and defined JScript.
On the other hand, "Java" is a programming language, core set of libraries, and virtual machine platform that allows you to create compiled programs that run on nearly every platform, without distribution of source code in its raw form or recompilation. While the two share part of their names in common, they are really two completely different programming languages/models/platforms. Yes, they can communicate with each other through technologies like LiveScript. However, you should really consider them as two completely separate technologies.
39) How can I determine if a file is a Java class file?

If the first four bytes of a file are not 0xCAFEBABE then you do not have a Java class file. This testing is done as part of the first pass of the Java verifier.
40) What are the differences between PATH and CLASSPATH environment variables?

The PATH environment variable is typically something that the operating system uses to find executable files. See the system manuals for your platform for more information.
The CLASSPATH environment variable is typically something that implementations of the Java Virtual Machine (JVM) use to find Java class files.
41) Can a Java class be static?

Yes and no. The static modifier is only applicable to so-called member classes -- i.e., classes which are directly enclosed within another class.
42) What does it mean to override a method?

If a subclass shares a method name with identical arguments and return type, it overrides the method of its superclass. Overridden methods may differ in exceptions thrown by throwing a more specific exception type or none at all.
43) How do I find out how much system memory is available in my system?

The Runtime class has two methods to help you determine memory resources: freeMemory() and totalMemory(). The freeMemory() method reports the free bytes in Java's memory space. The totalMemory() reports the total bytes in Java's memory space.
44) What is the difference between the stream tokenizer and string tokenizer?
You can think of the StringTokenizer as a specialized form of StreamTokenizer, where each token that is returned is a String. Depending upon what you want to do with the resultant tokens and/or how complex of a parse job you want to deal with lets you decide which to use.
The StringTokenizer parses a string into a series of tokens. It is then your responsibility to figure out what each token returned is, beyond the definition of a token separated by delimiters. Usually, you just treat things as words when using StringTokenizer.
On the other hand, a StreamTokenizer allows you to ask is the next token a number, word, quoted string, end-of-file, end-of-line, comment, or whitespace. In this case, the StreamTokenizer is smarter, though can be considerably harder to use.
45) Can I override the equals() method to take a parameter other than Object?

If you are trying to override a method with a different argument list, that isn't overriding, but overloading. In order for the method to be properly overridden, and thus called appropriately, the subclass method signature must explicitly match that of the superclass. In the case of equals() that means the return type must be boolean and the argument must be Object.

46) Should I declare the constants in my interface as public final static, and my methods as public abstract?

The use of the these modifiers in interfaces is completely optional. The following point out the relevant sections of the Java Language Specification:
 According to the section 9.1.5: All interface members are implicitly public.
 According to section 9.3: Every field declaration in the body of an interface is implicitly public, static, and final
 According to section 9.4: Every method declaration in the body of an interface is implicitly public and Every method declaration in the body of an interface is implicitly abstract
47) Why doesn't the Java runtime complain if the main() method isn't declared public?

With Sun's reference implementation, they introduced this bug into the 1.2 implementation and haven't fixed it through the 1.3 release. The main() method is supposed to be public static void but it seems any access modifier works fine.

48) Why are there so many different programming languages?

As is the case with most things in life, I believe there are multiple reasons for why we have so many programming languages. Here are what I believe to be the more significant reasons:
 Programming languages vary with respect to the speed with which programs written in them can be executed. So if you have a real-time application, you'd choose a language that would be capable of delivering results under the applicable time constraints. So for a problem in dynamic control, you might choose, say, C over C++ or Java.
 Certain application domains require programming languages that are specifically targeted for those applications. Cobol, for example, represents a language that was developed specifically for business applications. It is easy to learn by people without advanced degrees in computer science and it is efficient for what it was designed to do.
 Much early programming dealt with solving numerically intensive problems, such as problems encountered in scientific calculations. Fortran emerged as a favorite of many for such applications. I believe it continues to be a widely used language for solving numerically intensive problems on supercomputers.
 Many programming languages that have emerged from academic laboratories are a result of researchers trying mimic certain aspects of human cognition. Languages like Lisp and Prolog fall in this category.
 Another reason for why we have so many programming languages is purely evolutionary. Consider, for example, the evolution from C to C++ and then on to Java. As it began to be realized that we needed richer representations for our concepts and as we sought ways to make large programs more easily extensible and maintainable, the concepts of object-oriented programming came into existence. Then as we better understood what was meant by object-oriented programming through pioneering languages like Smalltalk, C led to the development of C++. And then as it dawned on us that the wide generality of C++ (with regard to inheritance, operator overloading, and other issues) could become a liability in some cases, Java emerged.
 As the role of computers as "information presentation devices" proliferated in the society, there emerged a concomitant need for languages designed specifically for formatting the visual display of information. Languages such as HTML, XML, and their variants are fulfilling those needs.
I suppose what it all means is that as we continue to deploy computers for solving previously unaddressed problems, we will try to use the languages we already know. But should they fall short of our needs for whatever reason, we as a society of programmers will invent new languages.
49) How can I prohibit methods from being overloaded?

The only relatively surefire way that I know of is to make the entire class final. I.e., since there's no way to subclass that class then nobody can overload that method.
50) How can I determine the version of the JRE at runtime?

Check the system properties:
51) What is a "marker" interface?

A so-called marker interface is a Java interface which doesn't actually define any fields. It is just used to "mark" Java classes which support a certain capability -- the class marks itself as implementing the interface. For example, the java.lang.Cloneable interface.
52) What is a static block and how should I use it?

Basically, static blocks are blocks defined within the body of a class using the static keyword but which are not inside any other blocks. I.e.,
public class shme
static int foo = 12345;

foo = 998877;
The primary use of static initializers blocks are to do various bits of initialization that may not be appropriate inside a constructor such that taken together the constructor and initializers put the newly created object into a state that is completely consistent for use.
In contrast to constructors, for example, static initializers aren't inherited and are only executed once when the class is loaded and initialized by the JRE. In the example above, the class variable foo will have the value 998877 once initialization is complete.
Note also that static initializers are executed in the order in which they appear textually in the source file. Also, there are a number of restrictions on what you can't do inside one of these blocks such as no use of checked exceptions, no use of the return statement or the this and super keywords.
Personally, I think this is yet another odd little wart in the Java language that is due to the fact that Java doesn't have first-class classes. Sigh.
53) Are classes that implement Serializable required to have no-argument constructors?

No. This is a common misconception. The deserialization process does not use the object's constructor - the object is instantiated without a constructor and initialized using the serialized instance data. The only requirement on the constructor for a class that implements Serializable is that the first non-serializable superclass in its inheritence hierarchy must have a no-argument constructor. (See for a more complete explanation). This makes sense: deserialization needs to reconstruct the entire object state, which includes the state of any superclasses. If the superclass is not itself serializable, then deserialization needs to instantiate that superclass from scratch - thus the requirement. For example, with the following class:
public class MySerializableClass implements Serializable {
you do not need a no-argument constructor. MySerializableClass meets all requirements because its first non-serializable superclass, Object, has a no-argument constructor. In the following example:
public class MyFirstClass {
public class MySecondClass extends MyFirstClass implements Serializable {
MyFirstClass has the default, no-argument constructor, so no other constructor is needed. If, however, MyFirstClass defined constructors which accepted arguments without also explicitly declaring a no-argument constructor, then you would get a NotSerializableExceptin when trying to serialize MySecondClass.
All the requirements for an object that implements Serializable are listed at
54) What is the purpose of using a static method?

A static method is simply a method that does not need an instance of a class to execute.
Static methods are most useful as utility methods in classes that don't require state. For example, the java.lang.Math class has several static methods that you can call for calculations. No state is needed, so you don't need an instance of the Math class to perform the methods.
You call static methods using the class name rather than an instance name. For example

int x = Math.max(x,y);
Static methods are often used to access class variables. Class variables are variables in the class that are declared static. There is only one instance of the class variables on the system, so they make a great place to store constant values, "global" counts, and singleton instances.
Often, developers will define variables like

private static int count = 0;
and define a methods to access it, like

public static int getCount() {
return count;
public static void incrementCount() {
This allows reading and modification of the class variables while retaining control of the values. Noone can directly access private class variables other than this class, so you can restrict the types of updates (for example, only incrementing the count).
Note that static methods cannot access any instance variables defined in the object. Why? Because you don't have an instance of the object to know which instance variables you want to access.
55) What are the differences between System.gc() and Runtime.gc()?

The methods are basically equivalent. Both suggest to the JRE that it might be a good idea if the garbage collector actually does some work now.
Specifically, System.gc () is a static method so it's a wee bit more convenient to use rather than having to do e.g., Runtime.getRuntime ().gc ().
56) How do I convert a java.sql.Timestamp to a java.util.Date?

While Timesteamp extends Date, it stores the fractional part of the time within itself instead of within the Date superclass. If you need the partial seconds, you have to add them back in.

Date date = new Date(ts.getTime() + (ts.getNanos() / 1000000 ));
57) What's the difference between an interface and an abstract interface?

Nothing. All interface's are, by definition, abstract. In fact, the JLS says that use of the abstract modifier is obsolete and therefore should not be used in new programs.
58) Why is method invocation in Java polymorphic but field access isn't?

The designers of the Java programming language feel that the lack of dynamic lookup on field accesses provides greater run-time efficiency. In addition, if people want dynamic lookup on fields then they can easily use an accessor (aka "getter") instance method instead of direct field access. I.e., they leave the tradeoff up to the programmer.
59) What is a package in Java?

Java programs are organized as sets of packages. A package comprises one or more compilation units. The naming of packages is hierachical and may comprise classes, interfaces, and sub-packages. Each package defines a namespace.
60) What is meant by compatible equals() and hashCode() methods?

In order for the Java Collections to work properly (and everything else in Java), the equals() and hashCode() methods must be compatible. Here, compatible means that if equals() reports that two instances are the same, then the hashCode() of both instances must be the same value.
61) If an object is an array, how do I find out its type?

Use the getComponentType() method of the class of the object that is the array.
public class ArrayReflection {
public static void main (String args[]) {
private static void printType (Object object) {
Class type = object.getClass();
if (type.isArray()) {
Class elementType = type.getComponentType();
System.out.println("Array of: " + elementType);
62) Does Java use pass by value or pass by reference semantics when passing parameters to methods?

Java passes parameters to methods using pass by value semantics. That is, a copy of the value of each of the specified arguments to the method call is passed to the method as its parameters.
Note very clearly that a lot of people confuse the "reference" terminology with respect to Java's references to objects and pass by reference calling semantics. The fact is, in dealing with Java's references to objects, a copy of the reference's value is what is passed to the method -- it's passed by value. This is, for example, why you cannot mutate the (original, caller's) reference to the object from inside the called method.
63) What is the difference between an API and a framework?

Here is a less formal definition:
A framework is a set of classes which handles the flow necessary to perform a complex task, but which requires plug-in classes specific to your application (database, app server), and which allows for additional plug-in classes to extend the functionality. For example, you could have a framework which handles the general flow of an online store. This framework would handle tasks such as "put item in shopping cart", "generate order on checkout", etc. On the other hand, you would need to provide the classes which enable the framework to persist the shopping cart to the database of your choice, to connect to a credit-card processor, to send orders to a warehouse, among other things. Further, if you wanted to decided that you wanted to offer monogramming, you would need to provide classes to do so, and the framework should make it easy to plug these in.
An API is really no more than a set of method signatures and other information necessary to use a class or set of classes. The API is totally distinct from the implementation. For example, a number of vendors have implemented the servlet API, each in a different way. The API by itself has no implementation.
A class library would have an API, as would a framework.
64) What are differences between type-casting and Data Conversion?
TypeCasting is a feature of the language whereby you are telling the compiler (and readers of your source code :-) that you explicitly want it to treat the object as if it were really of the type that you specified rather than it's actual type.
Data conversion is physically changing one chunk of data into another, often with interpretation.
The difference can be illustrated thus:
Object o = new String("1234");

String myString = (String)o;
This allows you to cast the type of o to it's proper type, String.
Data conversion:
String o = new String("1234");

Integer i = Integer.parseInt(o);
This converts the String "1234" into the Integer which represents the value 1234 (one thousand two hundred twenty four).
65) Why does Java not support function/method pointers/references ala C/C++?

Because Java is a more pure object-oriented language than C/C++. Function pointers and method references are ways of pulling apart the functionality of objects.
The Java, OO way of doing the equivalent is pass around an object reference where that object adheres to a particular interface and so you can invoke the appropriate methods.

No comments: