Total members 11895 |It is currently Sat Dec 21, 2024 4:11 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





What is a Class?
A class is a collection of attributes and behaviors of objects with certain similarities and an instance of a class is represented by an object.

What is an Object?
General, object is an entity that has fields and methods. In Java object is an instance of class and it contain values of fields .

How do you free memory in Java?
You can't, the GC cleans up free objects,You can set known references to null and call System.gc() . This later doesn't guarantee a clean up, but Sun's JVM does actual do a GC each time this is called.


When you declare a method as abstract method?

When i want child class to implement the behavior of the method.


How to make sure that I have single instance of class using singleton pattern in cluster environment?

In cluster environment the singleton class object should be put in JNDI tree. In this way applications will take the object of the instance from the JNDI tree instead of creating object in every application.

What is an Object?
An object is an entity which has fields and methods.

What is the need for Java?
When there were so many programming languages already available what was the need for another programming language.
To understand this let us take an example of a program that runs on a SONY TV remote control. This program can be written using a language (let us assume) called X. The remote control has an in-built chip on which this program will run. If we look at the functionality of a TV remote it is almost the same for any brand of TV. So by right the same program should be used on any brand of TV remote.

In reality it is not. Why? Because the in-built chip in different brand of TV Remotes maybe different. Therefore the same program has to run these two different chips, they have to be re-compiled in order to suit different chips in other words platforms. If there are 100 different brands, the same program has to be re-compiled 100 times to suit these 100 different brands. This is where the problem arises. That is why a new programming language was needed. And Java was the answer.


What are the static fields & static Methods?

Static filed there will be one copy of it in the class. About static methods; they can call only static methods, can't call non static methods and call only static fields.

What are the Final fields & Methods?
Final methods can't be overridden in the child class. Final fields can't take other values or re-reference to other object.

What are the uses of the wrapper classes?

Wrapper classes are related to the primitive variables. Wraps a primitive value of the corresponding type. (Like integer for int )

What is serialization?
Serialization means converting the java object into stream of bytes to save it state.

What are transient variables in java?
Transient variables are variable that cannot be serialized.

Explain garbage collection?
Garbage collection is automatic memory management that is responsible for removing unused variables and objects .The Objects that is no more needed and used in your program is collected as garbage and removed. This is happened when no reference to the object (reference equal null) .This process allow more space in heap and avoid full heap exception. The GC need to call the finalize function of the object.


When java developers declare a method as abstract method?

This is when we need the subclass to the define method and its behavior.

What is a Vector?
Vector is grow able array of objects.


What is the use of the finally block?

Finally is the block of code that executes always. The code in finally block will execute even if an exception is occurred. Finally will not execute when the user calls System. exit().

What is serialization?
Serialization means saving the state of an object.

What is de-serialization?
De-serialization means restoring the state of an object.

What is externalizable ?
externalizable is an interface that extends Serializable. There are two different methods writeExternal() and readExternal. This allow us to customize the output.

Can you make an instance of the Math class?
No, because the constructor of the Math class is private.

Does java have 'sizeof' operator?
No, there is no 'sizeof' operator in Java.

Is there any class superclass of all classes?

Yes, the Object class. But the super class of Object class is null.

If you have a final reference to Object, can you change it to other object?
No, you can't change the object, but you can change the data in the object.

Are Java methods virtual?
Java function work like virtual C++ functions. You can say yes if you think in it like that .but notice java static methods can't be overridden but it can be hidden.

How to take a copy of an object?
Using the clone function you can make a new copy from the object.

Can you define an inner class inside a java method?
Yes , Inner class can be defined inside a method and it can access the local variables of the method and the parameters if it is defined as final.


What are the Java data types with their sizes?

boolean (1byte)
byte (1byte)
char (2bytes)
short(2bytes)
int(4bytes)
long(8bytes)
float(4bytes)
double(8bytes)
void 0

How to start dead thread?
T|here is no dead state for threads, you can check if the thread is terminated or not using
Code:
isAlive()==false
function , or using
Code:
getState() == State.TERMINATED



In a class i have 10 variables... out of them i want to serialize
only 3 variables..how to do it?

you have to implement serializable interface and you have to declare variables
as transient which are not supposed to serialize.

In a class i have 2 methods.Each is associated with 2 threads (t1
for method1,t2 for method2).Both the methods r synchronized. .Now if i
call both the methods...will they execute simultaneously or not?
please explain?

it may lead to deadlock.

What is ORM file?
Object Relation Mapping in heard that it is used in Spring Frame work.

What is the default value in <load-on-startup> tag...what is the
difference among 0,1,2,3 etc...?


How people r saying that vector is a legacy class..what' s the logic
behind?

Vector is legacy class means it was built before the collection framework cames
without any synchronization. The Vector and Hash-table both are legacy class.
Which are implemented before Collection Framework is implemented.

What is difference b/w Class Variables and Instance?
Variables..and. .how can i find whether a variable is a CV r IV just by

looking at them in a class?
Class variables are declared as static with static keyword.
others are instance variables if they are not declared in method.

Think about the answers of the following :
Which method will be called first in a Form-bean class?
What is the difference between procedural and object-oriented programs?
What are Encapsulation, Inheritance and Polymorphism?
What is the difference between Assignment and Initialization?
What is OOPs?
What are Class, Constructor and Primitive data types?
What is an Object and how do you allocate memory to it?
What is the difference between constructor and method?
What are methods and how are they defined?
What is the use of bin and lib in JDK?
What is casting?
How many ways can an argument be passed to a subroutine and explain them?
What is the difference between an argument and a parameter?
What are different types of access modifiers?
What is final, finalize() and finally?
What is UNICODE?
What is Garbage Collection and how to call it explicitly?
What is finalize() method?
What are Transient and Volatile Modifiers?
What is method overloading and method overriding?
What is difference between overloading and overriding?

Is an Action class itself is Servlet or not?
How to synchronize a class?

What is permanent generation of JVM?




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

what are "java interview questions"?
are these asked in job interviews?
(noob question) :Blackeye:


Author:
Newbie
User avatar Posts: 4
Have thanks: 0 time

Yes :D

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

updated.

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 4 posts ] 

  Related Posts  to : java interview questions
 Java Important interview questions     -  
 Questions: Perl Script. PHP.     -  
 return false; questions     -  
 Real questions for BlackBerry BCP-211 exam     -  
 broken latest 1D0-435 test questions     -  
 Where do I get Oracle Certification Exam Questions?     -  
 Cisco 350-001 test exam Questions and Answers     -  
 passguide vcp-410 questions dumps download links     -  
 2d game in java-Monster-Java 2D Game Graphics and Animation     -  



Topic Tags

Java Basics






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com