GeekInterview.com
Series: Subject: Topic:

Core Java Interview Questions

Showing Questions 1 - 20 of 562 Questions
First | Prev | | Next | Last Page
Sort by: 
 | 

Can we serialize the static variable?

Asked By: Naresh | Asked On: Apr 2nd, 2006

Answered by: Ashish on: May 21st, 2012

static variable can not be serialized.... please follow find below example. Test3==> "java package a.b.c.d.e; import java.io.FileInputStream; import java.io.FileOutputStream;...

Answered by: vinaymudgil007 on: May 19th, 2008

No static variables can't be serialzed......

any doubts, let me know i can give an example???

Why class class is always the super class for every class

Asked By: Amit Rastogi | Asked On: Oct 5th, 2006

Answered by: ashish on: May 20th, 2012

1. Object is super class for all java classes.

2. even if someone want to make a class as subclass of CLASS class, he cant because class class is declared as final. so it can not be inherited

Answered by: vinaymudgil007 on: Jun 12th, 2008

java.lang.Object is the super class of all classes and NOT Class class

vinny

What are the difference between Java.SQL package and Javax.SQL package

Asked By: Babu varughese | Asked On: Feb 13th, 2007

Answered by: vijay on: May 18th, 2012

javax.sql provides connection pooling ,distributed transaction,disconnected rowsets

Answered by: sampra on: Feb 15th, 2008

java.sql.* package is used for the basic jdbc connections.
javax.sql.* package is used for the advance jdbc.  Advance is connection pooling, rowsets...ect.

How many ways we can create object ?

Asked By: kishore | Asked On: Nov 8th, 2006

Answered by: Sreenivasulu B on: May 17th, 2012

We can create an object in java by six ways.......

1.new operator
2.class.forName
3.Factory Method
4.Cloning
5.Deserialization
6.Reflection API

Answered by: Ghouse on: Mar 29th, 2012

In 5 ways

1. New operator
2. New instance
3. Clone
4 Factory method
5 De-Serialization

Is Java a fully object oriented programming or not? If not why?

Asked By: Beena | Asked On: Sep 16th, 2005

Answered by: karan0 on: May 16th, 2012

java does not support multiple parenting.

Answered by: Suresh on: May 15th, 2012

Pradeep, Does java supports Switch/Case trype of branching? Is this an OOPS concept?

What is difference between checked and unchecked exception ?

Asked By: Veera SEkhar | Asked On: Oct 18th, 2007

Answered by: inderjeet singh on: May 12th, 2012

Checked Exception represents the External Failure while Unchecked Exception represents the Internal failure.

Answered by: muktasharad on: Sep 5th, 2008

checked exceptions must be handeled.That is, a try-catch must either be nested around the call to the method that throws the exception.The compiler will throw an ...

What are the differences between arraylist and a vector

Asked By: Interview Candidate | Asked On: Sep 7th, 2005

Answered by: YUVARAJ on: May 11th, 2012

Array is a set of related data type and static whereas vector is a grow able array of objects and dynamic

Answered by: sampra on: Mar 13th, 2012

AL-non legecy/methods are not sysnchronized
Vector-legecy/method are synchronized

Abstract class and interfaces

Asked By: gvndrao | Asked On: Apr 30th, 2012

Where should we use exactly abstract class and interfaces?

Answered by: yuvaraj on: May 11th, 2012

All the methods declared inside an interface are abstract whereas abstract class must have at least one abstract method and others may be concrete or abstract. b) In abstract class, key word abstract...

If a class cannot be static how can an inner class alone be static ?

Asked By: gova007 | Asked On: Jan 22nd, 2012

Answered by: suvojyotysaha on: Apr 23rd, 2012

First ask yourself the question as to why is static used? Static helps us use those static members of the class directly, without creating an object. Second of all the outer classes are already perc...

What happens if public static void main(){} is made protected?

Asked By: venkat | Asked On: Nov 20th, 2007

Star Read Best Answer

Editorial / Best Answer

Answered by: Sushil Jain

Answered On : Nov 21st, 2007

You will be able to compile but it will through a run time error saying "main method not public".

Answered by: AA on: Apr 22nd, 2012

It will compile but gives error at run time......

Answered by: divya_mini4u on: Sep 21st, 2010

The complier will throw error that there is no main()  method. main() should be public always please note.

Explain when Java application can run out of memory ?

Asked By: janpachno | Asked On: Feb 12th, 2012

Answered by: Anon on: Apr 12th, 2012

if you have an infinite loop that keeps on doing things that take up memory (like creating objects).

Answered by: sampra on: Mar 6th, 2012

We all know Java automatically garbage collects unused objects. But you must remember that an object is considered as unused only when the object no longer referenced. That means a referenced class continues to exist and to take up memory space even if it is not used.

What is the difference between a callablestatement and preparedstatement?

Asked By: Swati | Asked On: Dec 29th, 2005

Answered by: Vasanth on: Mar 27th, 2012

Prepared statements can also execute a sql block or stored procedure.

But advantage of callable statement is it has registerOutParameter option.

If you want the OUT param value, you need to use CallableStatement alone.

Answered by: mc.thiru on: Jun 24th, 2010

PreparedStatement:
Use when you plan to use the SQL statements many times. The PreparedStatement interface accepts input parameters at runtime

CallableStatement:
Use when you want to access database stored procedures. The CallableStatement interface can also accept runtime input parameters.

Taking the build.

Asked By: ni3fasale | Asked On: Mar 22nd, 2012

What is mean by taking "build"? And which processes and modules of an application involved while taking builds.

What is the repeater function...And what does data integrity means?

Asked By: Nishit | Asked On: Oct 18th, 2005

Answered by: Sandhya.Kishan on: Mar 17th, 2012

The correctness and consistency of stored data is known as integrity of data.

What happens if we execute the program?Class return{ int display(){ try{ return 1; } finally{ return 2; }}public static void main(string args[]){ return r=new...

Asked By: sadashivarao | Asked On: Aug 11th, 2006

Answered by: sampra on: Mar 16th, 2012

Ans:2

Answered by: Pallu on: Sep 5th, 2006

You are right Sandeep.

But I guess, Sadashivrao did not set a classpath if he is executing this program on command prompt.

You can set classpath by:(if u saved Return.java in temp folder)

C:Documents and Settingsx.yDesktoptemp>set classpath=%classpath%;
C:Documents and Settingsx.yDesktoptemp

How does garbage collection work

Asked By: Interview Candidate | Asked On: Sep 1st, 2005

Answered by: sampra on: Mar 16th, 2012

gc called by jvm we dont hav any contol

Answered by: rvs_rs on: Oct 3rd, 2005

When Java was originally developed, the JDK shipped with a mark-and-sweep garbage collector. A mark-and-sweep garbage collector proceeds in two phases: Mark: identifies garbage objects Sweep: reclaims...

Abstract - how do you make object

Asked By: Sujit4175 | Asked On: Jun 23rd, 2011

If all the methods in the abstract class is defined, then it is a abstract class? And can we make object out of it?

Answered by: sampra on: Mar 16th, 2012

we cant create the instance of abstract class ..here we need sub class which extended this class .we can have ref var of abstract class

Answered by: Amit Khaware on: Jun 29th, 2011

First thing first, An abstract class without any abstract method means you are loosing the main intent fo abstractness, why we are making abstract class is to provide some of common implementation and...

Output of Java program

Asked By: khadarzone | Asked On: Apr 11th, 2008

What is the output of the following program?Class a{ public static void main(string[] s) { system.Out.Println(s[1] + s[2] + s[3]);}}Java a 12345options(i) 1(ii) 12(iii)1234(iv)234(v) compilation error

Star Read Best Answer

Editorial / Best Answer

Answered by: abuthahir.d

Member Since Jan-2008 | Answered On : Apr 14th, 2008

Khadar , i tried this code . it gives that exception

for the foll reason : 
 when u give a CLA(command line argument) , it will be inserted in the index 0 of the array and then will proceed to 1 ,2 ....

so as per the question , "12345" will be at s[0] . and length of that aray will be 1when u try to access s[1] , we are trying for 2nd element which is unavailable..... 


Hope this answers u  :-)

Answered by: sathish on: Mar 13th, 2012

Compilation error . System.out.println() is the syntaz not system.Out.Println

Answered by: mankal on: Mar 7th, 2012

arrayOutOfBoundException

Sort an arraylist having group of objects

Asked By: RamyaSuresh | Asked On: Mar 5th, 2011

Employee object having emp name, emp id, emp salary... An arraylist has a list of employee object.How will you sort this arraylist?

Answered by: Gaurav Singh on: Jul 13th, 2011

Implement the Comparator Interface for the Employee Class. Then customize your sort in the implemented method from interface

Answered by: NGKiran on: Mar 15th, 2011

Implement Comparable interface for the class Employee, customize your require in the implemented method from interface

First | Prev | | Next | Last Page

 

 

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Career Counselling

 Have Career Question?

 Ask Chandra

 Ask Only Career questions.

Follow us:
 

Latest Questions

Ads

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, click "Subscribe".