venkat_alladi

Greenhorn
+ Follow
since Jan 31, 2001
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 venkat_alladi

Congrats John
I just passed my SCJP and want to prepare for the Architect Exam.
I would apprecite if you give some suggestions on available resources for the architect exam
Thank you
Venkat
Please make the correction in my above post its
int i = f.read();
instead of
int i = inf.read();
Thank you
Thanks dominic.
The explanation makes sense but i was not able to justify it since the following code compiles without any error.
public static void main(String args[]){
FileInputStream f;
try{
f = new FileInputStream("test.txt");
int i = inf.read();
}
catch(FileNotFoundException f){
System.out.println(f);
}
catch(IOException e){
System.out.println(e);
}
}
Hi all,
The following code led me to think about
Scope of a variable declared/intialized in a try block?

for example
0. public static void main(String args[]){
1. FileInputStream f;
2. try
3 {
4 f = new FileInputStream("test.txt");
5 }
6 catch(FileNotFoundException f){
7 System.out.println(f);
8 }
9 try{
10 int i = f.read(); // Error at this line
11 }
12 catch(IOException e){
13 }
14 }
I get an C/T error at Line 10 as "f is not initialized".

Have you guys encountered this before.
I would appreciate some answers
Thank you
Hi Naveen
Thanks for the offer . I can't refuse it.
Pl. include my e-mail address in the list also.
Venkat
valladi@oakland.edu

a = "world";
is as good as saying
a = new String("world");
Hope this helps.
Venkat
1. overriding is hiding the super class implementation. There could be only one overriding method with the same signature as the superclass in the subclass.
2. whereas overloading is providing multiple forms of the method based on different arguement types. Java determines particular overloaded method to be executed during run time by late binding.
I would agree to the Mock exam question that overloading is polymorphism.
Static variables and methods are Class level. Instances of the class or the subclass share the variable or the method declared static.
The answer for your question is
static methods do not get inherited.
hope this helps
Venkat
Thanks for the correction Hungsen. I got the mistake i did with
the operators
Hi Guys
I am not able to justify swati's answer.
This is my view
byte b = 10; // is a valid decleration
The Compile time error occurs when the
setColor(30) call is made
since 30 is a integer and the
setColor(byte i) doesn't have an explicit type cast to int.
Please compile the code and see it for yourself's
--
Venkat
It means the following
int c;
switch(c){
case 0: Do something;
case 1:case 2:
switch (c){
case 0: Do something;
case 1: Do something;
}
}
The above switch is nested and inside switch arguement is the same as the one outside and they are independent.
Hope this helps.


------------------
The precedence is
Postfix ++, Prefix ++, Unary +
Hence the expression will be evaluated as
i = ++k + k++ + +k; k = 1
i = ++k + 2 + +k; k = 2
i = 3 + 2 + +k; k = 3
i = 3 + 2 + 3; k = 3
i = 7; k = 3
Hope this helps