Sreeram Desigan

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

Recent posts by Sreeram Desigan

if(b1)
{
// statements
}
here the statements will be executed only if b1 is true.
if(!b1)
{
//statements
}
here the statement will be executed only if b1 is false.
read if(!b1) as "if not b1" u can understand the meaning.
Hai Supriya, plz send the full code so that v can help u.
Contiue can be used only inside loops and if is not a loop. Further the label used for continue should be a loop label.
Hai the decision should be based on ur intensions. If u want a job the try 1.4 because it is easier than 1.5 u can score a lot. Scores are very important for interviews and to find jobs. Also 1.5 is not adopted in most of the top compaines and will not be for atleast a year. So go for 1.4 itself.
But if u want to learn a lot and dont have any urgency then go for 1.5. Its a real challenge.
The line B y = new A() will result in error because u can add a derived class object to a base class reference but not a base class reference to a derived class. Here A is a base class and B is a derived class.
The variable p in killer class constructor is a base class reference and it is made to refer derived class (User). when the base class reference refers to a derived class and a method is invoked using the reference then the derived class method is called. Hence the getName() method in User class is called. The method returns SName which is the User class variable. This variable is not yet initialized in the User class. Hence it has null value which is default initiaization for strings. The SName of user is different from the SName for Person. Initializing for Person is not sufficient for User.
Dear Raju,
It all depends on ur need. According to me there are no projects currently developed in 1.5v. So u r safe if u know 1.4 itself. Wat counts is ur score in exam and nothing else.
Then coming to the exam 1.5 syllabus is larger than 1.4, also in the exam they test ur coding ability. There is no test on ur memory which means that no or veryless direct questions. Every question needs application. So it is safer to take 1.4 now. If u need 1.5 at later stages go for updation exam.
Hi everyone,
I am very happy to inform u all that today (13th April) i took SCJP 1.4 and cleared the exam with 100%. Thanks a lot to this site. I have got lots of my doubts cleared from this site. Also friends please advice me what exam to take next. I am currently working in an IT consultancy and want to become a J2EE expert (including framework design).
19 years ago
But y is the first isInterrupted() in main immediately after interrupt() returns true.
I guess interrupt() method will set the interrupt status to true and moves thread a1 from waiting status to ready status. The main thread after executing this interrupt on thread a1 will call the isinterrupt() method which will check the status and return true. Now when the thread a1 moves from ready status to execution status it will throw InterruptedException and reset the Interrupt status. Thus the isInterrupted() method in the catch block will return false.
This what i guess has happened but i want a clear proof of it. Thats y i posted this question to know different views on it. But received no replies at all.
In a javabeat mock exam i found the following question
1 Which of the following can prevent a thread from executing?
(1) A call to its pause method
(2) A call to Thread.yield()
(3) Another thread is given higher priority
(4) A call to its halt() method

the answers are given as 2 and 3.
But according to me Thread.yield() method does not always prevent a thread from executing. It will move from executing state to ready state and the rest is platform dependent.
How can we say that 3 is a correct answer. Is't the priority implementation platform dependent.
Dear Gunj Agarwal,
The statement System.out.println(ref2.g()); calls the g() method in B class because ref2 is a reference of B and g() is not overriden in C. Now inside g() method we have the statement return f(); Now the call to f() can be considered as this.f() since this here denotes a class C object the java runtime checks if f() is overriden in C. Now since f() is overriden in C the method in C is called which returns 2 and 2 is printed.
Now if you make f() in B as private then the answer is 1 because private methods cannot be overriden. Hence the call return f(); in method g() of B will call the f() method in B itself. For anyother access modifiers of f() in B such as protected or default or public f() can be overriden.

Originally posted by J Sato:
Consider the following:


The first someMethod() does not throw any exceptions. The second someMethod() throws Exception which is the narrowest checked exception that can be thrown. The third someMethod() throws IOException and will not compile.




No Sato the method that throws IOException will not cause any error. Because IOException is all so a subclass of Exception. If u execute your code then an error may come because you did not import java.io.*; to use the IOException.
Ingeneral if the base class method throws an exception then the derived class method that overrides this method can either throw the same exception or subclass of the same exception or may not even throw an exception.
The round method in Math class is implemented something like this
round(double d)
{
return (long)Math.floor(d + 0.5);
}
Thus round(5.5) will return Math.floor(5.5 + 0.5) which is (long)6.0
and round(-5.5) will return Math.floor(-5.5 + 0.5) which is Math.floor(-5.0) which is (long)-5.0.
Dear Amisha,
According to me the answer for first question is both A and C because if C is true then A should also be true. That is if test class has a main method then the source file should be named as test.
For the second question the answers are A and D.
Am very sure these are the correct answers. If package statement is present then it must be the first non comment statement of the program.
And if a program has a public interface then the source file should be named as the interface name else compile time error occurs.
consider the following program
class A extends Thread {
public void run() {
try {
synchronized (this) {
wait();
}
} catch (InterruptedException ie) {
System.out.println("isInterrupted() inside catch is " + isInterrupted());
}
}
public static void main(String[] args) {
A a1 = new A();
a1.start();
a1.interrupt();
System.out.println("a1.isInterrupted() inside main is " + a1.isInterrupted());
}
}

--------
one of the output for this program is :
a1.isInterrupted() inside main is true
a1.isInterrupted() inside catch is false

why is this an output. As for the specification of thread method isInterrupted() method never resets the Interrupt flag of a thread.
Thanks to all. It was my mistake i was checking in 1.3 specification.