eknath wagadre


{ City } bangalore
< Country > india
* Profession * senior software engg.
User No # 94374
Total Questions Posted # 0
Total Answers Posted # 8

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 53
Users Marked my Answers as Wrong # 8
Questions / { eknath wagadre }
Questions Answers Category Views Company eMail




Answers / { eknath wagadre }

Question { 60892 }

can we declare private class in java file?


Answer

private and static keyword in java we can't use those
keyword any of the outer block. we can use those keyword
only and only inside of the block.(Block i.e Class )

NOTE: Outer class can't be private but inner class can be
private(bcz of this is the part of the outer class and also
inner class can be static.)

Is This Answer Correct ?    1 Yes 0 No

Question { Wipro, 11188 }

what is mean by custom tag?


Answer

Custom Tags user defined or predefined tag library. It's
using in jsp pages. but why we are using these tag we can
directly write the java code in jsp by using script-lets.

Bcz of this reason....Prventing to writing the java code
in JSP file or writing the business logic in jsp files for
this we need the Custom Tag.

We are keeping our java business logic in Our Tag Handler
class. we are not keeping our business logic in jsp

Is This Answer Correct ?    1 Yes 0 No


Question { KPIT, 6260 }

If your team member writes code with lots of static
variables and static methods, will it cause any side effects?


Answer

Yes!!! We can define the several static method and variable
and those are vary easy to access by Class Name or by class
instance.

But Only problem with static method and variable is that
there is Maximum chance of data corruption. bcz of static
method and variable are accessed by diff-2 thread at the
same time. Mean at the same time one or more then one thread
can change the value of static variable.

So conclusion is this if we can define more static variable
and method so and our program have hug line of code at that
time programs output may be inconsistent.

Is This Answer Correct ?    0 Yes 0 No

Question { Mind Tree, 24753 }

How many objects are created when we create String class
object using new operator?


Answer

No!!!!!!!!!!!!!!!!!!!!

According to the Question it will creating only One object
in the Heap only..........

if we are using String str = new String("abc"); for this
statement only one object is creating in the heap only....

if we are using the code like

String str = "abc";
String str = new String("abc");

In this case only one object is creating in the heap.bcz of
in first line obviously one object is creating in the pool
and assigning the reference(S) to abc. now come in second
line it's creating object in heap but jvm will checking for
reference(s) bcz both object reference is same so now (s) is
pointing to abc which is in heap and pool object is
collected by GC. now we have only one object is heap.


if we are using the code like

String str ="abc";
String str1 = "abc";
String str2 =new String("abc");

Then only two object is creating one in string content pool
and another one is in heap.

Thank's
Eknath

Is This Answer Correct ?    16 Yes 6 No

Question { 3434 }

what are the analysis of an object


Answer

Object in java is Big Thing...........

Object is a real time entity which has
Name,behavior,attribute,action so many thing. so when we
analyzing any object we have to analyze all these thing like
this..
Name : Name of the Object as Name of the class
Behavior : What is the behavior of that object
Attributes : What is the attribute of the object such as for
Student objct his age,roll no,marks etc.
Action: What operation we have to perform on that attribute
of student object ....

I think this the object analysis....wrt programming.

Is This Answer Correct ?    1 Yes 0 No

Question { 6037 }

Can we override the main method?


Answer

I think Sadikhasan Palsaniya answer is wrong....

Well... the answer is NO!!!! Why it's No...

if you think from the perspective of how an overriden method
should behave in Java. But, you don't get any compiler error
if you try to override a static method. That means, if you
try to override, Java doesn't stop you doing that; but you
certainly don't get the same effect as you get for
non-static methods. Overriding in Java simply means that the
particular method would be called based on the run time type
of the object and not on the compile time type of it (which
is the case with overriden static methods). Okay... any
guesses for the reason why do they behave strangely? Because
they are class methods and hence access to them is always
resolved during compile time only using the compile time
type information. Accessing them using object references is
just an extra liberty given by the designers of Java and we
should certainly not think of stopping that practice only
when they restrict it :-)


Example: let's try to see what happens if we try overriding
a static method:-


class SuperClass{

......

public static void staticMethod(){

System.out.println("SuperClass: inside staticMethod");

}

......

}


public class SubClass extends SuperClass{

......

//overriding the static method

public static void staticMethod(){

System.out.println("SubClass: inside staticMethod");

}


......

public static void main(String []args){

......

SuperClass superClassWithSuperCons = new SuperClass();

SuperClass superClassWithSubCons = new SubClass();

SubClass subClassWithSubCons = new SubClass();


superClassWithSuperCons.staticMethod();

superClassWithSubCons.staticMethod();

subClassWithSubCons.staticMethod();

...

}


}


Output:-


SuperClass: inside staticMethod

SuperClass: inside staticMethod

SubClass: inside staticMethod


Notice the second line of the output. Had the staticMethod
been overriden this line should have been identical to the
third line as we're invoking the 'staticMethod()' on an
object of Runtime Type as 'SubClass' and not as
'SuperClass'. This confirms that the static methods are
always resolved using their compile time type information only.

Is This Answer Correct ?    3 Yes 0 No

Question { Google, 15250 }

What is private static final long serialVersionUID = 1L;


Answer

serialVersionUID is final static and private variable and
the value of the variable will be genreted by the jvm and
it's used for serialization and deserialization of object.

Is This Answer Correct ?    20 Yes 1 No

Question { Crimson Logic, 21292 }

why HashTable not allow null key and value


Answer

To successfully store and retrieve objects from a hashtable,
the objects used
as keys must implement the hashCode method and the equals
method.

In a nutshell, since null isn't an object, you can't call
.equals() or .hashCode() on it, so the Hashtable can't
compute a hash to use it as a key.

HashMap is newer, and has more advanced capabilities, which
are basically just an improvement on the Hashtable
functionality. As such, when HashMap was created, it was
specifically designed to handle null values as keys and
handles them as a special case.

Specifically, the use of null as a key is handled like this
when issuing a .get(key):

(key==null ? k==null : key.equals(k))

Is This Answer Correct ?    11 Yes 1 No