Core Java 2
Home Up Core java Core Java 2 Everything Else Core Java 3 Java Network Unanswered Questions

 

Java Interview Questions

Visit Java Interview Homepage
 
<<< Previous Page

Next Page >>>

Q5. A note on PUBLIC , PRIVATE , STATIC , VOID & MAIN.

A5. (i) All Java applications begin execution by calling main ()

(ii) When a class member is defined as public. Then that member may be accessed by code outside the class in which it is declared.

(iii) The opposite of public is private which prevents a member from being used by code defined outside of its class.

(iv) The keyword static allows main() to be called without having to instantiate a particular instance of the class. This is mandatory because main () is called by the Java interpreter before any objects are made.

(v) CASE SENSITIVE : Main () is different from main(). It is important to know that that Main() would be compiled. But the Java interpreter would report an error if it would not find main().



 

Q6. What is meant by Garbage collection ?

A6. The technique that automatically destroys the dynamically created objects is called garbage collection. When no reference to an object exists, that object is assumed to be no longer needed , and memory occupied by that object can be reclaimed.



 

Q7. What are the access modifiers?

A7. There are three types of access modifiers.

(i) Private - Makes a method or a variable accessible only from within its own class.

(ii) Protected - Makes a method or a variable accessible only to classes in the same package or subclasses of the class.

(iii) Public - Makes a class , method or variable accessible from any other class.



 

Q8. A note on keywords for Error handling.

A8. (i) Catch - Declares the block of code used to handle an exception.

(ii) Finally - Block of code , usually following a typecatch statement, which is executed no matter what program flow occurs when dealing with an exception.

(iii) Throw - Used to pass an exception up to the method that calls this method.

(iv) Throws - Indicates the method will pass an exception to the method that called it.

(v) Try - Block of code that will be tried but which may cause an exception.

(vi) Assert - Evaluates a conditional _expression to verify the programmer's assumption.



 

Q9. How many ways can you represent integer numbers in JAVA?

A9. There are three ways , you can represent integer numbers in JAVA. They are decimal (base 10) , octal (base 8) , and hexadecimal (base 16).

<<< Previous Page

Next Page >>>

Search this site for:

 

Please use this form to communicate any issues/problems with this website or its contents. If you find any content inappropriate for any reason, please let me know. Hit Counter