question 29)
what will happen when you attempt to compile and run the following code with the command line "hello there"
public class arg{
string[] myarg;
public static void main(string argv[]){
myarg=argv;
}
public void amethod(){
system.out.println(argv[1]);
}
}
1) compile time error
2) compilation and output of "hello"
3) compilation and output of "there"
4) none of the above
question 30)
what will happen when you attempt to compile and run the following code
public class streq{
public static void main(string argv[]){
streq s = new streq();
}
private streq(){
string s = "marcus";
string s2 = new string("marcus");
if(s == s2){
system.out.println("we have a match");
}else{
system.out.println("not equal");
}
}
}
1) compile time error caused by private constructor
2) output of "we have a match"
3) output of "not equal"
4) compile time error by attempting to compare strings using ==