Jini Varghese

Ranch Hand
+ Follow
since Dec 06, 2000
Merit badge: grant badges
For More
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 Jini Varghese

Hello,
This question is from applied reasoning mock test.
Select all true statements.
a.It runs only when memory is low.
b.It handles circular references.
c.It can be invoked by executing, System.gc().
d.As soon as there are no more ref, the object is Gced.
e.None of the above.
Ans: e.
I thought c will be an answer. You can invoke GC but it may not run. Please explain why c is wrong.
Thanks in advance.
I have some doubt about the following question.
Which of the following statements about Java's garbage collection are true?
a) The garbage collector can be invoked explicitly using a Runtime object.
b) The finalize method is always called before an object is garbage collected.
c) Any class that includes a finalize method should invoke its superclass' finalize method.
d) Garbage collection behavior is very predictable.
I think b, c.
The finalize() method will eventually be called on every object -true or false.
Ans is given False, there is no guarantee that an object will be GCed.
I think it's true.
Please correct me if I am wrong.
Thanks
XOR
Here's a question.
1. byte b1 = -5;
2. int i = 0xff;
3. byte b2 = (byte)(b1 ^ i);
4. b2++;
5. System.out.println(b2);
ans is 5, How? Can anyone explain, please?
b1 will be 1111 1101, will get promoted to int before ^.
i will be 1111 1111.
After ^, 0000 0010. After that ?
Thanks.
Class fields with the following modifiers will not be serialized.
1.private
2.static
3.transient
4.protected
ans : 2,3
Isn't it only 3 ?.
Thanks.
True or False.
An anonymous class can be static.
We can have anonymous class inside a static block, right?. So will this statement be true?.
Thanks.
List is an interface. Where is the set() method implemented ? Or asList() method is returning a class that implements List, which has implemented all the List methods?
import java.util.Arrays;
import java.util.List;
public class ArrayDemo4 {
public static void main(String args[]) {
Object vec[] = {new Integer(37), new Integer(47)};
List lst = Arrays.asList(vec); //return list
lst.set(1, new Integer(57));
for (int i = 0; i < vec.length; i++) {
System.out.println(vec[i]);
}
}
}
Thanks
The second one, with final modifier still gives error.
See the code.
List is an interface. Where is the set() method implemented ? Or asList() method is returning a class that implements List, which has implemented all the List methods?
import java.util.Arrays;
import java.util.List;
public class ArrayDemo4 {
public static void main(String args[]) {
Object vec[] = {new Integer(37), new Integer(47)};
List lst = Arrays.asList(vec); //return list
lst.set(1, new Integer(57));
for (int i = 0; i < vec.length; i++) {
System.out.println(vec[i]);
}
}
}
Thanks
Can anyone, please, give me an eg showing explicit event enabling(using MASK) and how to close a window in it?
Where should I give the window closing code?.
Thanks
Great...That really helped. Thanks a lot.
What would happen when the following is compiled and executed. Select the one correct answer
public class compare {
public static void main(String args[]) {
int X=10,y;
if(X<10) y=1;<br /> if(X>=10) y=2;
System.out.println("y is "+y);
}
}
a. the program compiles and prints y is 0 when executed
b. the program compiles and prints y is 1 when executed
c. the program compiles and prints y is 2 when executed
d. the program does not compile complaining about y not being initialized
e. the program throws a runtime exception
ans :d
I did the code and the answer is d. But y is given value for all (+ve and -ve) values of X. So why compiler complains? Is there anything that I am missing here?
Thanks in advance...