Samy Venkat

Greenhorn
+ Follow
since May 26, 2003
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 Samy Venkat

Hi Dan,
For the below program why 'f' is also included in the answer.
Which of the following statements are true in terms of the java.lang.Math.abs method?
a. Four overloaded versions of abs exist.
b. An ArithmeticException is declared in the throws clause.
c. The type of the return value depends on the type of the argument.
d. The returned value is always of a floating-point primitive type.
e. If the argument is greater than or equal to zero then the returned value is equal to the argument.
f. If the argument, arg, is less than zero then the returned value is -arg.
Thx
Hi all,
Finally, after month long trepidation, I passed SCJP 1.4 with 86%. Thanks to all of greenhorns here in Javaranch. I referred the following four books and attendted almost all mock exams available in the web. The one provided by Dan was very..very..very... useful. Apart from the questions on each topic, the explanation given for each quesion under answer section was embedded with many details. The exam questions were not that difficult as Dan's. (I presume Dan is not in Sun's question setters panel ).
1) Kathy & Berts - Java Certification 310-035
Book. - Greatly helpful. Thanks to the
authors and publishers for making the
contents of CD ROM(e-book) copyable to hard
disk.
2) Java Certification 2- Second Edition by Simon
Robers.
3) Mike Mayer's Passport to Java Certification.
4) Java certification by Brian Bagnal. (Inner
Class chapter was fine)
Although all of the above book were teaching the syllabus for the exam, each book highlighted some essestial unknown facts. For example, Mike Myers' passport to certification highligted the return values for max,min...etc..for all inputs like NaN, Positive Infinity, Negative Infinity. If time permits, for anyone appearing for the exam, pls. refer more than one book.
Thank you all again.
SAMY.,
18 years ago
Hi all,
Finally, after month long trepidation, I passed SCJP 1.4 with 86%. Thanks to all of greenhorns here in Javaranch. I referred the following four books and attendted almost all mock exams available in the web. The one provided by Dan was very..very..very... useful. Apart from the questions on each topic, the explanation given for each quesion under answer section was embedded with many details. The exam questions were not that difficult as Dan's. (I presume Dan is not in Sun's question setters panel ).
1) Kathy & Berts - Java Certification 310-035
Book. - Greatly helpful. Thanks to the
authors and publishers for making the
contents of CD ROM(e-book) copyable to hard
disk.
2) Java Certification 2- Second Edition by Simon
Robers.
3) Mike Mayer's Passport to Java Certification.
4) Java certification by Brian Bagnal. (Inner
Class chapter was fine)
Although all of the above book were teaching the syllabus for the exam, each book highlighted some essestial unknown facts. For example, Mike Myers' passport to certification highligted the return values for max,min...etc..for all inputs like NaN, Positive Infinity, Negative Infinity. If time permits, for anyone appearing for the exam, pls. refer more than one book.
Thank you all again.
SAMY.,
[ June 08, 2003: Message edited by: Samy Venkat ]
18 years ago
My question is why both of the print statements are printing 'z'.
System.out.println("value of c in StaticVars: " + sv.c);
System.out.println("value of c in SuperStatic: " + sc.c);
The assignment to sub class variable should not affect the super class variable. Pls. explain
[ June 06, 2003: Message edited by: Samy Venkat ]
Hi anyone pls. explain why the below code prints z?
class StaticVars {
static char c = 'a';
}
public class SuperStatic extends StaticVars {
public static void main(String [] args) {
StaticVars sv = new StaticVars();
SuperStatic sc = new SuperStatic();
sc.c = 'z';
System.out.println("value of c in StaticVars: " + sv.c);
System.out.println("value of c in SuperStatic: " + sc.c);
}
}
Thx.,
class Overload001{
int print(int a,long b, long c){
return (int)(a+b+c);
}
int print(long a,int b, long c){
return (int)(a+b+c);
}
public static void main(String sam[]){
Overload001 ol1=new Overload001();
System.out.println(ol1.print(1,2,3));
}
}
The above code doesn't compile because the compiler cannot determine which method to call. How method calls are resolved. Is it based on the first parameter or method with all parameter matching. But below code is working. Pls. explain.
public class Overload002{
private void locate(double a, long b){
System.out.println(a*b);
}
private void locate(float a, int b){
System.out.println(a*b);
}
public static void main(String arg[]){
new Overload002().locate(1.0,2);
}
}
In the above program, based on the first parameter the with double should be called. But based on the second parameter, second locate method should be called. Pls. explain. Thanks.
Can any one explain, why the following code prints "Sample". Thx.
public final class Test4 {
class Inner {
void test() {
if (Test4.this.flag); {
sample();
}
}
}
private boolean flag = false;
public void sample() {
System.out.println("Sample");
}
public Test4() {
(new Inner()).test();
}
public static void main(String args []) {
new Test4();
}
}
Try the below program.
class A {
void m1(A a) {System.out.print("AA");}
void m1(C c) {System.out.print("CC");}
}
class B extends A {
void m1(B b) {System.out.print("B");}
}
class C extends B {
void m1(C c) {System.out.print("C");}
}
class D20 {
public static void main (String[] args) {
A c1 = new C();
C c2 = new C();
c1.m1(c2);
}
}
This prints C. When a method is overridden and when a sub-class object is assigned to super class reference, then only the sub-class method is called or else super class version only be called. If i am wrong pls. correct me. Thx.
If the selection of method was based on reference, why the below example prints AAB, instead of
AABB. That means, if the most suitable method(with out implicit conversion) is availble then the
method call is dispatched to that class in the hierarchy. Am i right? Pls. explain..thx.
class A {
void m1(A a) {System.out.print("AA");}
void m1(B b) {System.out.print("AB");}
void m1(C c) {System.out.print("AC");}
}
class B extends A {
void m1(B b) {System.out.print("B");}
}
class C extends B {
void m1(C c) {System.out.print("C");}
}
class D16 {
public static void main(String[] args) {
A c1 = new C();
A c2 = new C();
B b1 = new B();
c1.m1(c2);
c1.m1(b1);
}
}
[ May 28, 2003: Message edited by: Samy Venkat ]