Deepthi Kanakam Rajan

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

Recent posts by Deepthi Kanakam Rajan

Thanks a lot Bert ....i realise now that writing exams like SCJP involves plenty of code writing and I am definitely going to make it a point to install all the required softwares and practice well for my SCWCD exam.

Thanks once again ....your book is truly awesome!
18 years ago
Hi All

I managed to clear SCJP 1.5 with 77%. I have no prior experience in Java and many tried to discourage me from appearing for 1.5 as they felt the topics would be hard to master for someone like me

However, books like K&B and Khalid Mughal (for OOPs)helped me a lot as much as mocks like Marcus Green ( i really must thank Marcus as I used to send him emails regarding some obscure query of mine and he would promptly respond),Whizlabs (very good software) ,skillfox and javablackbelt(amazing site again though it has more of 1.4 questions) .

I prepared for this exam without having jdk1.5 installed on my machine for the major part of the preparation but a big thanks to java ranch and the numerous queries posted there everyday that helped me understand many of the core concepts.

Thanks once again.

Regards

Deepthi Rajan
18 years ago

Originally posted by pandoo pandoo:
line 1 public class Asserttest3
2 {

3 public static Boolean message()
4 {
5 System.out.println("Error");
6 return new Boolean("true");
7}
8 public static void main(String[] args)
9{
10 boolean b =false;
11 assert b:message();
12 int x = -5;
13 assert(x+1)>0;
14 assert x>0 x= x * -1);
15 assert !b;
16 while(true)
17 {
18 System.out.println(x);
19 assert x-- > 0;
20 }
21 }
22 }


Find out the line which used the assertion inappropriately.

Select multiple options:
1) line 11
2)line 13
3)line 15
4)line 19
5)line 14



i donot find any wrong in the above assertion used except none included any try/catch for assertion error.what could be the output.?



Hi Pandoo

I think the answers should be lines 19 and 14 ie 4 and 5.Assertions should not cause any side-effects when used because it can disbaled at runtime.

In both lines 14 and 19 the value of variable x is changed.
Hi All

Does assigning generic types to a raw type generate unchecked warnings or is it the other way round?

I am really confused about this as Whizlabs has mentioned the above statement while the document on Generics by Gilad Bracha states that assigning a raw type to a generic type generates unchecked warnings.

Appreciate a clarification on this.

Thanks in advance.

Originally posted by Deepthi Kanakam Rajan:
[QB][/QB]



sorry forgot to add my query to that which is according to K&B book its mentioned that:

One can box and then widen and not the other way while your statement contradicts it.

Can you please clarify this as I am confused now

Thanks

Originally posted by Burkhard Hassel:
You cannot first box and then widen!

But the other way round, it works:Integer i=(int) s.charAt(2);

here, the char is first widened to an int primi.
This int primi then can be boxed to an Integer.



Yours,
Bu.[/QB]

Hi,

This is one of the questions given in epracticelabs demo exam:

import java.util.*;

public class PayRoll
{

public static void main(String argv[])
{
Vector<String>employeeList = new Vector<String>();

Vector<Integer>employeeIdList = new Vector<Integer>();

Vector<Object>employeeProfileList = new Vector<Object>();

System.out.println(employeeList.getClass()==employeeIdList.getClass());
System.out.println(employeeList.equals(employeeProfileList);
System.out.println(employeeList.getClass()==employeeProfileList.getClass());
System.out.println(employeeIdList.equals(employeeProfileList);

}
}

the answer gven is false false false true.

teh reason given that all instances of a generic class have the same runtime class so getClass() returns java.util.Vector.

In that case, the answer should have been true true true true.

Appreciate a clarification on this.

Thanks in advance.
The following code:

class A
{
int x=5;
}

class B extends A
{
int x=6;
}

public class CovariantTest
{
public A getObject()
{
return new A();
}

public static void main(String args[])
{
CovariantTest c1 = new SubCovariantTest();

System.out.println(c1.getObject().x);
}
}

class SubCovariantTest extends CovariantTest
{
public B getObject()
{
return new B();
}
}


The answer given is 5 though i feel is should have been 6.

Can someone please clarify this.

Thanks in advance.
Hi,

I would like to know if questions on Unicode are included for the SCJP 5 exam.

Thanks in advance.
Thanks Neelesh. a mistake on my part
This is a question given in the K&B book chapter 8: Inner classes page 659 Question 3:

public interface Runnable
{

void run();

}


which construct an anonymous inner class instance?

A. Runnable y = new Runnable() {};

B. Runnable y = new Runnable(public void run(){ });

C. Runnable y = new Runnable { public void run() { } };

D. Runnable y = new Runnable() { public void run(){ }};

E. System.out.println(new Runnable() {public void run() { }} );

The answer given in the book is E but i feel that option D can also be considered as a correct option.

Can someone please clarify this?

Thanks in advance.
Thanks guys.i understood how the code works.
Can someone please explain how the following code works:

class Stepper
{
enum Roman{I,V,X,L,C,M}

public static void main(String args[])
{
int x=7;
int z=2;

Roman t = Roman.X;

do
{

switch(t)
{
case C: Roman.L;break;
case X: t= Roman.C;
case L: if(t.ordinal()>2) z+=5;
case M: x++;
}
z++;
}while(x<10);
System.out.println(z);
}
}

how does the ordinal() work?

Thanks

Deepthi Rajan