Varsha Joshi

Greenhorn
+ Follow
since Jan 06, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Varsha Joshi

Hi

I couldn't get how the value of "this.nat" is "dub" ....

please elaborate on this some more...

Thanks in advance...

Varsha
Thanks Everyone for reply....

now i am through this concept

Thanks,
Varsha
You can also go for Whizlabs SCJP5.0 preparation kit. You can get information about this from site
http://www.whizlabs.com/scjp/scjp-5.0-details.html

This provides good mock tests..

Thanks,
Varsha
Hi Ponraj

As per my understading the line "byte b = 16" works becuase the value is in byte range that is -128 to 127.
If you try to assign the value out of range it will throw compile time error.

If you try to compile the line "byte b = 16.2", you will get compile time error:
possible loss of precision
found : double
required: byte
byte b =16.2;
^
1 error

so if you compile line "byte b = 16.2" with the explicting cast as "byte b = (int)16.2", you get output as 16 which is the integer of part of number 16.2.

Regards,
Varsha
One of the from Mock Exam

class A
{
int x = 5;
}
class B extends A
{
int x = 6;
}
class CoVarTest
{
public A getObject()
{
System.out.println("A");
return new A();
}
public static void main(String[] args)
{
CoVarTest c1 =new Test();
System.out.println(c1.getObject().x);
}
}
class Test extends CoVarTest
{
public B getObject()
{
System.out.println("B");
return new B();
}
}

The output is:
B
5

My Doubt is the method c1.getObject() calls the method "public B getObject()", then why the value of x 5 instead of 6?
I know that overriding is not for variables they are choosen at compile time.

Please provide some thought on this......

Thanks in Advance.

Regards,
Varsha
Thanks Henry.... The explaination helped me a lot to understand the logic...

Thanks and Regards,
Varsha
Hi,
The following is program from one of the mock test.

public class SplitTest {
public static void main(String[] args) {
String s = "Aaaaah, This is Program";
String[] s1 = s.split("a", ?); // ?
for(String str:s1)
System.out.print(str);
}
}
If the required output of program is : Ah, This is Program

Then what should be the value of "?" in the split() method?
I have selected the value of limit as "4" but answer was wrong. The correct value is "5".
Can anyone explains how come the value of limit is 5 instead of 4,as "aaaa" "a" expression has occured 4 times in the given string?

Thanks in Advance.

Regards,
Varsha
you can refer to "SCJP 1.5 Book - Kathy Sierra and Bert Bates" it contains number of practice exam questions and exercises.
Also Java Certification book by Khalid Mughal is also good but I don't have idea whether author has come up with 1.5.

Regards,
Varsha
Thanks Nitesh.....

I got my answer
Wanted to confirm whenter the following sentence is true or false:

"Assigning null to a reference causes the object to become eligable for garbage collection "

As I was solving one mock exam and I choose this answer as true but my answer was wrong so just got confused....

also please provide some details on this.