Hello and Greetings,
Please explain the following:
1) public class Emp{
int i[] = {0};
public static void main(
String args[]){
int i[] = {1};
change_i(i);
System.out.println(i[0]);
}
public static void change_i(int i[]){
int j[] = {2};
i = j;
}
}
If arrays behave like objects the answer should be 2. But the correct answer is 1. Why?
2. Is the following legal ( ie,Are two package statements legal?).
package pkg;
package pkg2;
import java.awt.*;
class c{};
3. I think following should give error because we are trying to put int in to char with out cast. But it compiles fine. Why?
char c = 32; //is Legal.
4. byte x = 3;
x = ( byte ) ~ x ;
System.out.println(x);
I think x can be -4 as well as 252, but the correct answer is -4. Please explain.
Reason for 252:
Binary of byte x = 3: 00000011
~3 = 11111100 = 252
5. Does delete() in the File class actually delete a file or just deletes an instance of the File Class?
Regards
Vineet