putti don

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

Recent posts by putti don

Hi Everyone,

Could anyone please explain me how the following works?

1> Servlet code:
Integer i=new Integer(3);
request.setAttribute("integer",i);

JSP:${integer le 12}....answer is true.

My doubt is how Integer object is converted to primitive int?

2> String num="2";
request.setAttribute("num",num);

JSP: ${num > 3}......answer is false
Hi All,
I passed the scjp 1.4 exam with 95% on Saturday.
Thanks to all ranchers.
19 years ago
Hi A kumar,

This kind of initialization should happen along with declaration..

int scores[]=new int[](1,2};


public class Test{
public int scores[];
public void Test(){
scores = new int[]{0,0,0,0}; // 1

}
compiles fine for me...
Hi,
public class Test19 {
float f;

Test19(float f){
System.out.println(f);
}

Test19(){
Test19(1);
f = 3;
}


public static void main(String args[]) {
Test19 t = new Test19();
}
}
why i am getting compile time error for this?can anyone please explain.
Thanks.
Hi,
I found this question in one of the mock exam...

Question :
What is the result of compiling & executing the following code ?

class Object {

String str ;

Object ( String str ) {
this . str = str ;
}

public String toString ( ) {
return str ;
}
};

class Ques extends Object{

Ques ( String str ) {
super ( str ) ;
}

public static void main ( String args [ ] ) {
Ques x = new Ques ( " My Object " ) ;
System . out .println ( x. str ) ;
}
};

Options :

a . Compiler error since you cannot redeclare a class that already exists
b . Compiler error since the extends clause does know which Object class to extend from
c . Prints something that denotes the state of the object x
d . Prints My Object

ANS is option d. But when i compiled this program i got error. can anyone please explain what is the correct output?

Thanks.
Hi,

class Th extends Thread
{
public void run(){System.out.println("ABC");}
public static void main(String a[])
{
Th th=new Th();
Thread t=new Thread(th);
t.start();//1
t.run();//2
}
}
output is ABC
ABC
I understood that at line 1 the run() method of the Runnable object th is called. But why is the output of line 2 ABC...should that be calling the run() method(which will not print anything) of Thread class?

Thanks.
When taking a mock exam i came across this statement "an array can contain elements of any type but they must all be of the same type".

But if we consider a primitive array
double d[]={'c',3.4f,33,44.4};
it can have any value that can be promoted implicitly to the declared type of the array.

Doesn't this contradict the statement "an array can contain elements of any type but they must all be of the same type"?
Hi,
can anyone please tell me what are compile time constants?
1>final int a=10; //Is this a compile time constant?
2>int b=0;//Is this a compile time constant?
3>Is it like,all variables that are marked final are compile time constants?

Thanks.
Hi,

I have purchased K&B book...can anyone please tell where to register the book to download the master exam. i couldnot register it in the site osborne.com.

Thanks.
Hi,
class Testx {

int i = getX();
int j = 10 ;

int getX ( ) {
return j ;
}

public static void main ( String args [ ] ) {
System . out . println ( new Testx ( ) . i ) ;
}
}

can anyone explain why the output of the above program is 0? why not 10?
Thanks.
Hi,
Consider the following line of code :
Thread t = new Thread( anObjectOfMyClass );
Which of the following could be a valid declaration of MyClass?
1>MyClass extends Thread
2>MyClass implements Thread
3>MyClass implements Threadable
4>None of these.

the answer is option 4..My doubt is why can't it be option 1(as Thread class implements Runnable)?

Thanks.
Hi,

I think the question is not about switch statement...it is about valid labels.
21: is not a valid label. A label should be a valid identifier.
21 is not a valid identifier.
Correct me if i am wrong.
Thanks.
class C {
public static void main(String[] args) {
Boolean b1 = Boolean.valueOf(true);
Boolean b2 = Boolean.valueOf(true);
Boolean b3 = Boolean.valueOf("TrUe");
Boolean b4 = Boolean.valueOf("tRuE");
System.out.print((b1==b2) + ",");
System.out.print((b1.booleanValue()==b2.booleanValue()) + ",");
System.out.println(b3.equals(b4));
System.out.println(b3==b4);
}}

Answer is true,true,true,true.

My doubt is whether Boolean.valueOf(...) returns a new Boolean object? If yes, then why b1==b2 and b3==b4 are true.

Thanks.
class A
{
String name;
}

class B extends A
{
private String name;
public void setName(String n){name=n;}
public String getName(){return name;}
}

class A is not tightly encapsulated.What about class B(as it is extending a class which is not tightly encapsulated)?Is it tightly encapsulated?

Thanks.
Hi,
are x2 and mx pointing to same object after the method m1() returns in line 4?
Thanks.