Swathi Sree

Greenhorn
+ Follow
since Aug 27, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Swathi Sree

Hi Ganesh,

Thank you for the reply.

If the comment //Demo.java is not given in the question, what should we infer?

Do we need to think that both classes are in different files?
Hi All,

If there are two public classes in a single file, it gives compiler error.

If there is a question on this concept how would it be asked, Does the file name will be mentioned in question or do we need to assume that two classes are in single file if the file name is not mentioned?

Please clarify.
Hi All,

Does the following class override equals method correctly?

public class TestClass {

private int i=6;

public boolean equals(Object obj){
if(obj instanceof TestClass){
return(i == ((TestClass)obj).i);
} else
return false;
}
}

1. The given code is not enough to validate equals method
2. equals method is overridden correctly
3. equals method is not overridden correctly

Which one is correct option?

Another Question is
Which method must be overridden if equals method is overridden?
1.hashCode()
2.wait()
3.finalize()

Answer given is hashCode().

My doubt is can we assess the equals method without providing the hash code method?
Hi,

As part of explanation to the question on identifiers, I have seen the following.

Java identifiers can contain any alphabets (a-z and A-Z), any digits and combining character '_' and currency symbols like $,Yen(symbol is given), pound(symbol) even though identifier should not start with a digit.

I know that $ can be used as part of identifier and also it can be used as first letter in the identifier name. My doubt is can we give an identifier name which starts with Yen symbol or Pound symbol? If yes how can we print those characters?

Please clarify.
Hi,

I have understood the concept of how the instance variables are changing while using threads(If there exists two threads with same instance of runnable then they operate on the same copy of the variable i.e original value otherwise they operate on different copies of instance variable.).

How come we can give true to this statement "Threads operate on their own copies of instance variables not on the originals".

How does the change of instance variables dependent on threads only? It is also dependent on which instance it is working. Can we say T/F for the above statement? Will real exam go for the statements like this?
Hi All,

Thank you for the above explanations, But by mistake I have given var j.

My doubt is regarding variable i which is instance variable.
j is static thus, it will be incremented twice.

But i is instance variable and the statement given(before code) is mentioning that different threads will have their local copies of instance variables.

That is where I confused. Please clarify.
Hi,

I have read the following statement in some mock test to select T/F, and the answer is true.
"Threads operate on their own copies of instance variables not on the originals".

If I run the following code, I am getting the r.j value 2.

class MyRunnable implements Runnable {
int i=0;
static int j=0;
public void run(){
int k=0;
increment(k);
System.out.println(k); //line 1
}
private void increment(int k){i++; j++; k++;}
}
public class Question33{
public static void main(String[] args) throws Exception{
MyRunnable r = null;
Thread t1 = new Thread(r=new MyRunnable());
Thread t2 = new Thread(r);
t1.start();t2.start();
t2.join();t1.join();
System.out.println(r.i+","+r.j); //line 2
}
}

How does the above statement is true?

Please clarify.
Thank you All for the explanation.
Hi,

The link is good and is discussing about how Garbage collector marks the objects that are not reachable.

But I am not able to find whether Garbage collection is platform dependent or not?
Hi,

In one of the mock tests, I have come across the following statement.

Iteration through Linked list is faster than Arraylist.

I have given answer False, but the answe given is True.

I am confused whether it is true or false.

Any body please explain.
Hi All,

Thank you very much for the great explanation.

Regards,
Swathi.
class Test1 {

public static void main(String[] args) {
System.out.println(Float.POSITIVE_INFINITY == Double.POSITIVE_INFINITY);
}
}

--------Output--------
true
----------------------

This would answer your question
Hi All,

I am trying to assign value to char variable. It is accepting the integer literal with '\' preceding. ex:'\61' is accepted as char literal. where as '\81' is not accepted. Compile time error msg "unclosed character literal" is given.

Any body please tell me how to recognize which integers are allowed in quotes with '\'. And also I have doubt whether this type of questions will araise in SCJP?

Regards,
Swathi.
Hi,

Compressing the data is great idea. Thankyou for guiding me in that direction. I have tried by compressing the data while sending through network, I could not find the difference in time of loading after compressing.

If I save the file from the JSP, it is saving correctly but opening the file again is becoming problem. I tried saving as csv but it didn't work for me. Some junk data is coming in to the file.

One thing I noticed is, saved xls file is taking 85MB space, which is 8MB if I copy the data and save it as xls file manually. As I am using response.setContentType("application/vnd.ms-excel"); the excel is opening in webpage and is being saved as web page xls.

I do not understand why this is taking 10times more memory than that of normal excel file.

Is there any way to open the excel as only excel file not as excel in webpage?

Thanks & Regards,
Swathi.
16 years ago
JSP
Hi Daniel,

First of all Thank you for the reply. The loading time is more if I am trying to show the data in excel. If it is jsp, it is taking normal time.

Any idea of how would it effect if the browser shows data in excel? any information regarding comparision of load time for jsp to excel?

Thanks & Regards,
Swathi.
16 years ago
JSP