ravi jain


{ City } delhi
< Country > india
* Profession *
User No # 41845
Total Questions Posted # 3
Total Answers Posted # 35

Total Answers Posted for My Questions # 14
Total Views for My Questions # 23145

Users Marked my Answers as Correct # 137
Users Marked my Answers as Wrong # 27
Answers / { ravi jain }

Question { KPIT, 6231 }

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


Answer

Abhinav pls explain more.

Is This Answer Correct ?    0 Yes 1 No

Question { Ness Technologies, 6803 }

Nullpointer exception is a very common exception. Why is it
not made as a checked exception?


Answer

when some operation is done with an object which is not
initialized i.e. object is "null" than NullPointerException
occurs.

This exception is in category of unchecked exceptions because
instance are not available at compile time so how complier checks whether object is null or instantiated, so it is
treated as unchecked exception.

Is This Answer Correct ?    18 Yes 0 No


Question { Ness Technologies, 15439 }

When you say String is immutable, what do you mean by that?
Say I have String s = "Ness"
s= s+"Technologies";
What will happen? If the value gets appended, then what is
the meaning of immutable here?


Answer

When concatenation operator "+"
used with string

it always creates a new String object,
in String pool area.

Is This Answer Correct ?    11 Yes 0 No

Question { Huawei, 9039 }

question on Thread synchronization


Answer

Synchronization is a
process of controlling the access of shared resources by
the multiple threads in such a manner that only one thread
can access a particular resource at a time.

Is This Answer Correct ?    5 Yes 0 No

Question { 4623 }

who can we create the object of a class? in how many ways we
can create it (max 5)


Answer

through

1) String s = "This is my Object";

2) String s1 = s.subString(1,8);

3) int[] arr = {12,45,12}; every array is an object.

4) String s2 = s + s1;

these all are also create new instances.

Is This Answer Correct ?    1 Yes 0 No

Question { Oracle, 6685 }

Read data from console and print in one file. That would be
in C:\temp ? Thanks, Bose


Answer

good answer pushpa.. :)

Is This Answer Correct ?    1 Yes 2 No

Question { SunGard, 9413 }

Can u write constructor in abstract.If yes den when it will
be invoked.


Answer

Question is not properly defined!
U r asking abt

1. Contructor's modifier
2. constructor in abstract class

if(2nd)
{
than answer 1 & 2 are correct
}
else if (1st)
{
than answer 3rd is correct
}

Is This Answer Correct ?    2 Yes 1 No

Question { 13358 }

Hi Friends, can u give me Real Time example for interface
and abstract class.(With Banking Example)


Answer

Above answer is excellent answer...

thank you "Pushpa" for this great answer

Is This Answer Correct ?    6 Yes 0 No

Question { 4786 }

Hi Friends, I am beginner in java. what i know about
synchonized keyword is,If more that one 1 thread tries to
access a particular resource we can lock the method using
synchronized keyword. Then after that how the lock is
released and how next thread access that.Please explain with
example.


Answer

The lock is released when the holding thread exits the
synchronized block or an exception is occurred in execution.

Is This Answer Correct ?    0 Yes 0 No

Question { 4786 }

Hi Friends, I am beginner in java. what i know about
synchonized keyword is,If more that one 1 thread tries to
access a particular resource we can lock the method using
synchronized keyword. Then after that how the lock is
released and how next thread access that.Please explain with
example.


Answer

ok i agree with u ejp

wat abt this ??

thread invokes wait() method..

is holding remains in synchronized block or it exists.

Is This Answer Correct ?    0 Yes 0 No

Question { HCL, 7100 }

StringBuilder s = new StringBuilder("Hello
Mom");s.append(",I mean,Mother");
Response.Write(s.ToString());


String s = "Hello Mom";
s+ = ",I mean Mom";
Response.Write(s);

Which is faster ? which uses the most memory?


Answer

First one is faster

because in 1st only one object is created,
but in 2nd one three objects are created.

Is This Answer Correct ?    1 Yes 0 No

Question { Accenture, 8499 }

System.out.println(101/14)
what is the output?
a)6
b)14
c)7.14
d)0


Answer

Ans is 7

Is This Answer Correct ?    9 Yes 0 No

Question { 21216 }

Given:
10. interface A { void x(); }
11. class B implements A { public void x() { } public
voidy() { } }
12. class C extends B { public void x() {} }
And:
20. java.util.List list = new java.util.ArrayList();
21. list.add(new B());
22. list.add(new C());
23. for (A a:list) {
24. a.x();
25. a.y();;
26. }
What is the result?
1 Compilation fails because of an error in
line 25.
2 The code runs with no output.
3 An exception is thrown at runtime.
4 Compilation fails because of an error in
line 20.


Answer

Compilation fails because of an error in
line 25.

because interface A has no method definition for method y()
....

Is This Answer Correct ?    9 Yes 4 No

Question { 17449 }

11. static class A {
12. void process() throws Exception { throw new Exception();
}
13. }
14. static class B extends A {
15. void process() { System.out.println(”B”); }
16. }
17. public static void main(String[] args) {
18. new B().process();
19. }
What is the result?
1 B
2 The code runs with no output.
3 Compilation fails because of an error in
line 12.
4 Compilation fails because of an error in
line 15.


Answer

Compilation fails

static keyword not allowed here
at line 11 and 14

Is This Answer Correct ?    9 Yes 3 No

Question { Infosys, 19032 }

Given:
1. package test;
2.
3. class Target {
4. public String name = “hello”;
5. }
What can directly access and change the value of the
variable name?
1 any class
2 only the Target class
3 any class in the test package
4 any class that extends Target


Answer

a class which in same package
can access its variable name
no any class can access variable

1. class has default visibility so accessible in same package,
2. variable has public accessibility, can be access any class
which allowed in first condition.

Is This Answer Correct ?    1 Yes 0 No

Prev    1    [2]   3    Next