• Welcome to Valhalla Legends Archive.
 

Java Test (Long Topic)

Started by Denial, November 22, 2003, 01:52 AM

Previous topic - Next topic

Denial

For-Loop :

//Q 1-Examine the following code:

public class Loop1 {
public static void main (String args []) {
int total = 0;
for (int i = 0, j = 10; total < 30; ++i, --j) {
System.out.println(" i = " + i + " : j = " + j);
total += (i + j); }
System.out.println("Total " + total);
}
}

/*Select the most appropriate answer:
A. Produce a runtime error.
B. Produce a compile time error.
C. Print out "Total 0"
D. Will run infinitely.
E. Generate the following as output:
i=0: j=10;
i=1: j=9;
i=2: j=8;
Total 30
F. None of these.
*/

//Q-2 Examine the following code:

class Loop2 {
public static void main(String args[]) {
outer : for( int i=0; i<2; i++ )
{
System.out.println("# 1");
for( int j=0; j<3; j++ )
{
continue outer;
System.out.println("# 2"); }
}
}
}

/*Select the most appropriate answer:
A. Will not compile.
B. Produce output #1 #2 #2 #1 #2 #2 #2
C. Will run infinitely.
D. Will produce a runtime error.
E.  None of these.
*/

//Q 3: Examine the following code:

class Loop3 {
public static void main(String args[]) {
int counter=2;
zee:
for(int i=10;i>0;i--) {
tv:
int j=0;
while(j<10) {
if(j>1)
break tv;
if(i==j) {
counter++;
continue zee;
   }
 }
counter--;
}
System.out.println(counter);
 }
}

/*Select the most appropriate answer:
A. Will produce a runtime error.
B. Will not compile.
C. Will run infinitely.
D. Will produce 8
E. Will produce 9
F. None of these.
*/

//Q-4 Consider the following code:

class Loop4 {
public static void main(String args[]) {

int i=1,j=1;
for( ; ; )
 {
   if(i>5)break;
   else
   j+=i;
   i=0;
System.out.println(j);
   i+=j;
   }
 }
}

/*Select the most appropriate answer:
A. Will produce a runtime error.
B. Will produce a compile time error.
C. Will run infinitely.
D. Will produce 2
E. Will produce 2, 4, 8
F. None of these.
*/

//Q-5 Consider the following code:

class Loop5 {
public static void main(String args[]) {
int a=4,i,j;
if (++a<5)
break;
else {
loop: for (i = 1; i < 3; i++){
for (j = 1; j < 3; j++) {
if (a == 5) {
break loop;   
  }
}
System.out.println(i * j);
    }   
     }
  }
}

/*Select the most appropriate answer:
A. Will produce a run time error
B. Will produce a compile time wrror.
C. Will run infinitely.
D. Will produce 1, 1, 2 , 2, 1, 2
E. Will produce 1, 2,  2, 4
F. None of these.
*/

//Q-6 Consider the following code:

class Loop6 {
public static void main(String arga[]) {
int i=0;
for(i=1;i<=5;System.out.println(i++));
i++;
System.out.println(i);
 }
}

/*Select the most appropriate answer:
A. Will not compile.
B. Will produce a run time error.
C. Will run infinitely.
D. Will print 0
E. Will print 1 to 5
F. Will print 1 to 6
G.Will print 1 to 7
H. None of these.
*/

//Q-7 Consider the following code:

class Loop7 {
public static void main(String args[]) {
int j=0;
for(int k=0;!(j+k!=10);j++,k++)
System.out.println(k+" "+j);
 }
}

/*Select the most appropriate answer:
A. Will produce a compile time error.
B. Will produce a run time error.
C. Will run infinitely.
D. Will produce the following output:
    0  0
    1  1
    2  2
    3  3
    4  4
E. Will print i and j from 1 to 9.
F. Will not print anything.
G. None of these.
*/   

//Q-8 Consider the following code:

class Loop8 {
public static void main(String args[]) {
 
       for(int i = 0; i < 5; i++){
 
          if (i < 2)
             continue;
         
           if ( i == 4)
             break;
   
           System.out.println("Value of i:" + i);      
       }  
  }
}

/*Select the most appropirate answer:
A. Will produce a compile time error.
B. Will produce a run time error.
C. Will run infinitely.
D. Will produce nothing.
E. Will produce the following output:
    Value of i:2
    Value of i:2
    Value of i:4
F. Will produce the following output:
    Value of i:2
    Value of i:3
G. None of these.
    */


//Q-9 Consider the following code:

class Loop9 {
public static void main(String args[]) {
int b=1;
while(++b>0)
;
System.out.println("_A_A");   //Guess???
  }
}

/*Select the most appropriate answer:
A. Will produce a compile time error.
B. Will produce a run time error.
C. Will run infinitely.
D. Will not print anything.
E. Will print "_A_A"
F. None of these.
*/

//Q-10 Consider the following code:

class Loop10 {
public static void main(String args[]) {
char i;
in:
for(i=0;i<5;i++) {
switch(i++) {
case  '0': System.out.println("0");
case  1: System.out.println("1"); break in;
case  2: System.out.println("2"); break;
case  3: System.out.println("3");break;
case  4: System.out.println("4");
case '5': System.out.println("5");
         }
      }
   }
}

/*Select the most appropriate answer:
A. Will produce a compile time error.
B. Will not print anything.
C. Will print "0",  "1"
D. Will print "2"
E. Will print "2", "3", "4"
F. Will print "2",  "4",  "5"
G. None of the above.
*/

OVERLOADING, OVERRIDING, INNER CLASSES, CONSTRUCTORS

Question Number 1:

Consider the following class definitions:

class Base{}
class Subclass1 extends Base{}
class Subclass2 extends Base();
//Now consider the following declarations:
Base b = new Base();
Subclass1 s1 = new Subclass1();
Subclass2 s2 = new Subclass2();
//Now, consider the following assignment:
s1 = (Subclass1)s2;

Which of the following statements are correct regarding this assignment

A. The assignment is legal and compiles without an error. No exception is thrown at runtime.
B. The code fails to compile. The compiler complains that the assignment "s1 = (Subclass1)s2" is illegal.//
C. The code compiles but ClassCastException is thrown at runtime.

D. The code fails to compile. You cannot subclass a parent class more than once.

Question Number 2

Consider the following:
class A extends Integer{
    int x = 0;
}

Select all valid statements.

A. The code will compile correctly.

B. The code will not compile because Integer is final and cannot be subclassed.//

C. The code will not compile because class A has no methods or constructor.
D. The code will compile correctly, but will throw an ArithmeticException at runtime.




Question Number 3:

Which variables can an inner class access from the class which encapsulates it.

A. All static variables//

B. All final variables//

C. All instance variables//

D. Only final instance variables

E. Only final static variables

Question Number 4

Which of the following keywords can be applied to a top-level class (i.e., not an inner class)?
A. private
B. protected
C. transient
D. public//
E. final//

Question Number 5

What is displayed when the following piece of code is compiled and executed:

class Test{
    public static void main(String [] args){
        Base b = new Subclass();
        System.out.println(b.x);
        System.out.println(b.method());
    }
}

class Base{
    int x = 2;
    int method(){
        return x;
    }
}

class Subclass extends Base{
    int x = 3;
    int method(){
        return x;
    }
}

A. Nothing. The code fails to compile because the object b is not created in a valid way.

B. 2//
   3

C. 2
   2

D. 3
    3

E. 3
   2

Question Number 6

You have a class with a certain variable and you don't want that variable to be accessible to ANY other class but your own. Your class must be sub-classable.
Which keyword do you add to the variable.

A. private//
B. public
C. transient
D. final
E. abstract

Question Number 7

Which of the following classes override the equals() method.

A. String//
B. Integer//
C. Double//
D. Date//
E. File//

Question Number 8

Analyse the following 2 classes and select the correct statements.

class A{
    private int x = 0;
    static int y = 1;
    protected int q = 2;
}
class B extends A{
    void method(){
        System.out.println(x);
        System.out.println(y);
        System.out.println(q);
    }
}

A. The code fails to compile because the variable x is not available to class/
B. The code compiles correctly, and the following is displayed:  0 1 2
C. The code fails to compile because you can't subclass a class with private variables.
D. Removing the line "System.out.println(x)" will allow the code to compile correctly.
E. The compiler will complain that the variable x in class B is undefined.

Question Number 9

Which of the following are defined in the Object class?

A. toString()//
B. equals(Object o)//
C. public static void main(String [] args)
D. System.out.println()
E. wait()//

Question Number 10

Select the valid code fragments from the following list:

//A. public transient static final int _FRAMEX = 850;

//B. this("a", "b");
[assuming a constructor of the type xxx(String, String) exists for this class]

//C. private transient static final int _FRAMEX = 850;

D. boolean b = 0;

Question Numer 11

Consider the following code and select the most appropriate statements.

1. class Test{
2.    public int doubleValue(int a)
3.         System.out.println(a);
4.         return (int)(a * 2);
5     }
6.
7     public float doubleValue(int a){
8.         System.out.println(a);
9.         return (float)(a * 2);
10.   }
11.}

A. The code compiles since the two doubleVal() methods  have different return types.

B. The code doesn't compile because the compiler sees two methods with the same signature. //

C. The code can be made to compile by redefining the parameter for doubleVal() on line 7 to be "float a" instead of "int a".//

D. The code can be made to compile by replacing the  public declaration on line 7 with private.

Consider the following piece of code:
Question Number 12

class Test{
         int x;
         String s;
         float fl;
         boolean [] b = new boolean [5];
         public static void main(String []args){
              System.out.println(x);
              System.out.println(s);
              System.out.println(fl);
              System.out.println(b[2]);
              }
         }

What is displayed when this code is executed.
A. 0
   null
   0.0
   false
B. 0
   " "
   0.0
   true
C. Nothing. The code fails to compile because the boolean array is incorrectly declared.
D. Nothing.  The code will not compile because the static method cannot access the variables since there is no instance of the Test class.//

Question Number 13

Which line of code can be inserted in place of the comments, to perform the initialisation described by the comments:

    public class T {
         int r;
         int s;
         T(int x, int y) {
              r = x;
             s = y;
         }
    }
    class S extends T {
         int t;
         public S(int x, int y, int z){
              // insert here the code
              // that would do the correct initialisation
              // r= x  and s= y
              t=z;
         }
    }

A. T(x, y);
B. this(x, y);
C. super(x, y);//
D. super(x, y, z);
E. None

Question Number 14

Consider the following piece of code:

class A{
    int x = 0;
    A(int w){
        x = w;
    }
}
class B extends A{
    int x = 0;
    B(int w){
        x = w +1;
    }
}

A. The code compiles correctly.

B. The code fails to compile, because both class A and B do not have valid constructors.

C. The code fails to compile because there is no default no-args constructor for class A. //

Question Number 15

Consider the following piece of code and select the correct statement(s):
public class Test{
    final int x = 0;
    Test(){
        x = 1;
    }
    final int aMethod(){
        return x;
    }
}

A. The code fails to compile. The compiler complains because there is a final method ("aMethod") in a non-final class.

B. The code compiles correctly. On execution, an exception is thrown when the Test() constructor is executed.

C. The code fails to compile because an attempt is made to alter the value of a final variable.//

D. Removing the "final" keyword from the line "final int x = 0" will allow the code to compile correctly.//

E. The code fails to compile because only methods can be declared as final (and therefore "final int x = 0" is not valid).

Question Number 16

Consider the following piece of code and select the correct statement(s):

1. class A{
2.     protected int method(){
3.     }
4. }
5.
6. class B extends A{
7.     int method(){
8.     }
9. }

A. The code fails to compile, because you can't override a method to be more private than its parent.//

B. The code fails to compile, because method() is declared as protected, and is therefore not available to any subclass.

C. The code compiles correctly, but throws a NullPointerException at runtime.
D. The code fails to compile. However, it can be made to compile correctly by prefixing line 7 with the access qualifier "public".//

E. The code fails to compile. However, it can be made to compile correctly by prefixing line 7 with the access qualifier "public".//


Question Number 17

What is the output of the following program?

1.    class Test {
2.      void show() {
3.         System.out.println("non-static method in Test");
4.      }
5.    }
6.    public class Q3 extends Test {
7.      static void show() {
8.         System.out.println("Overridden non-static method in Q3");
9.      }
10.      public static void main(String[] args) {
11.         Q3 a = new Q3();
12.      }
13     }

1) Compilation error at line 2.
2) Compilation error at line 7.
3) No compilation error, but runtime exception at line 2.//
4) No compilation error, but runtime exception at line 7.

Question Number 19

What is the output of the following program?

1.   public class Q11 {
2.     static String str1 = "main method with String[] args";
3.     static String str2 = "main method with int[] args";

5.     public static void main(String[] args) {
6.        System.out.println(str1);
7.     }

10.     public static void main(int[] args) {
11.       System.out.println(str2);
12.     }
13.   }

1) Duplicate method main(), compilation error at line 5.
2) Duplicate method main(), compilation error at line 10.
3) Prints "main method with String[] args".//
4) Prints "main method with int[] args".

Question Number 20

What will happen when you try compiling and running this code?

public class Ref{
public static void main(String argv[]){
         Ref r = new Ref();
         r.amethod(r);
         }
         public void amethod(Ref r){
         int i=99;
         multi(r);
         System.out.println(i);
         }
         public void multi(Ref r){
         r.i = r.i*2;
         }
}

1) Error at compile time//
2) An output of 99
3) An output of 198
4) An error at runtime

Question Number 21

What will happen when you compile and run the following code?

public class Scope{
private int i;
public static void main(String argv[]){
               Scope s = new Scope();
           s.amethod();
       }//End of main
       public static void amethod(){
                System.out.println(i);
       }//end of amethod
}//End of class

1) A value of 0 will be printed out
2) Nothing will be printed out
3) A compile time error//
4) A compile time error complaining of the scope of the variable i

Question Number 22

What will happen when you attempt to compile and run the following code?

public class Inc{
public static void main(String argv[]){
             Inc inc = new Inc();
             int i =0;
             inc.fermin(i);
             i = i++;
             System.out.println(i);
     }

     void fermin(int i){
             i++;
     }
}

1) Compile time error
2) Output of 2
3) Output of 1
4) Output of 0//

Question Number 23

public class MyClass1 {
public static void main(String argv[]){ }

/*Modifier at XX */ class MyInner {}
}

What modifiers would be legal at XX in the above code?

1) public//
2) private//
3) static//
4) friend

Question Number 24

Given the following class definition

public class Upton{
public static void main(String argv[]){
     }
     public void amethod(int i){}
     //Here
}


Which of the following would be legal to place after the comment //Here ?

1) public int amethod(int z){}
2) public int amethod(int i,int j){return 99;}//
3) protected void amethod(long l){ }
4) private void anothermethod(){}//

Question Number 25

Consider the following definition:

1.  public class Outer {
2.  public int a = 1;
3.  private int b = 2;
4.  public void method(final int c) {
5.  int d = 3;
6.  class Inner {
7.  private void iMethod(int e) {
8.
9.   }
10. }
11. }
12. }

Which variables may be referenced correctly at line 8?

A. a//

B. b//

C. c//

D. d

E. e//

Question Number  26

For a class defined inside a method, what rule governs access to the variables
of the enclosing method?

1) The class can access any variable
2) The class can only access static variables
3) The class can only access transient variables
4) The class can only access final variables//

Question Number 27

What will happen when you attempt to compile and run the following code

public class As{
int i = 10;
int j;
char z= 1;
boolean b;
public static void main(String argv[]){
               As a = new As();
               a.amethod();
       }
       public void amethod(){
          System.out.println(j);
          System.out.println(b);
       }
}

1) Compilation succeeds and at run time an output of 0 and false//
2) Compilation succeeds and at run time an output of 0 and true
3) Compile time error b is not initialised
4) Compile time error z must be assigned a char value

Question Number 28

You are writing a set of classes related to cooking and have created your own exception
hierarchy derived from java.lang.Exception as follows:

Exception
+-- BadTasteException
+-- BitterException
+-- SourException

Your base class, "BaseCook" has a method declared as follows:

int rateFlavor(Ingredient[] list) throws BadTasteException

A class, "TexMexCook", derived from BaseCook has a method which overrides
BaseCook.rateFlavor().  Which of the following are legal declarations of the overriding method?

1) int rateFlavor(Ingredient[] list) throws BadTasteException//
2) int rateFlavor(Ingredient[] list) throws Exception//
3) int rateFlavor(Ingredient[] list) throws BitterException//
4) int rateFlavor(Ingredient[] list)//

Question Number 29

Given the piece of code, select the correct to replace at the comment line?

class A {
        A(int i) { }
}
public class B extends A {
          B() {
                  // xxxxx
           }
         public static void main(String args[]) {
                B b = new B();
         }
}

1) super(100);//
2) this(100);
3) super();
4) this();

Question Number 30

Given the following class definition which of the following can be legally
placed after the comment line //Here ?

class Base{
public Base(int i){}
}

public class MyOver extends Base{
public static void main(String arg[]){
               MyOver m = new MyOver(10);
               }
       MyOver(int i){
               super(i);
       }
       MyOver(String s, int i){
               this(i);
                              //Here

       }
}

1)MyOver m = new MyOver();
2)super();
3)this("Hello",10);
4)Base b = new Base(10);//

Question Number 31

You are given a class hierarchy with an instance of the class Dog. The class Dog is a child of
mammal and the class Mammal is a child of the class Vertebrate. The class Vertebrate has a
method called move which prints out the string "move". The class mammal overrides this
method and prints out the string "walks". The class Dog overrides this method and prints out
the string "walks on paws". Given an instance of the class Dog,. how can you access the
ancestor method move in Vertebrate so it prints out the string "move";

1) d.super().super().move();
2) d.parent().parent().move();
3) d.move();
4) none of the above;//

Question Number 32

Given the following code

class Base{
static int oak=99;
}

public class Doverdale extends Base{
public static void main(String argv[]){
     Doverdale d = new Doverdale();
     d.amethod();
     }

     public void amethod(){
     //Here
     }      
}

Which of the following if placed after the comment //Here, will compile and modify the
value of the variable oak?

1) super.oak=1;//
2) oak=33;//
3) Base.oak=22;//
4) oak=50.1;

Question Number 33

What is the output of the following code?

   1:    class Test
   2:    {
   3:        Test(int i)
   4:        {
   5:            System.out.println("Test(" +i +")");
   6:        }
   7:    }
   8:
   9:    public class Q12
   10:   {
   11:        static Test  t1 = new Test(1);
   12:
   13:        Test         t2 = new Test(2);
   14:
   15:        static Test  t3 = new Test(3);
   16:
   17:        public static void main(String[] args)
   18:        {
   19:            Q12 Q = new Q12();
   20:        }
   21:    }

   1) Test(1)
      Test(2)
      Test(3)

   2) Test(3)
      Test(2)
      Test(1)

  3) Test(2)
     Test(1)
     Test(3)

  4) Test(1)
     Test(3)
     Test(2)//

Question Number 35

Given the following code snippet

1.   class A {
2.     public void method(int a, float b) {
3.         // some declaration and etc.
4.     }
5.   }

6.    public class B extends A {
7.      //Comment here ?
8.    }

In class B what all methods can be placed in (// Comment here ?) individually ?

1) void method(int i, float a)
2) public void method(int i, float f)//
3) public void method()//
4) protected int method(float f, int b)//

Question Number 36

Name the keyword which makes a variable belong to a class, rather than being defined
for each instance of the class. Select the one correct answer.

1) static//
2) final
3) abstract
4) native
5) volatile
6) transient

Question Number 37

What will happen if you compile/run the following code?

   1:  public class Q21
   2:  {    
   3:      int maxElements;
   4:
   5:      void Q21()
   6:      {
   7:          maxElements = 100;
   8:          System.out.println(maxElements);
   9:      }
   10:
   11:     Q21(int i)
   12:     {
   13:          maxElements = i;
   14:          System.out.println(maxElements);
   15:     }
   16:
   17:     public static void main(String[] args)
   18:     {
   19:          Q21 a = new Q21();
   20:          Q21 b = new Q21(999);
   21:     }
   22:  }

   1) Prints 100 and 999.
   2) Prints 999 and 100.
   3) Compilation error at line 3, variable maxElements was not initialized.
   4) Compillation error at line 19.//

Question Number 38

Consider the following class

1.   class Tester {
2.      void test (int i)    { System.out.println ("int version"); }
3.      void test (String s) { System.out.println ("String version"); }
4.
5.      public static void main (String args[]) {
6.        Tester c = new Tester ();
7.        char ch = 'p';
8.        c.test (ch);
9.      }
10.   }

Which of the following statements below is true?(Choose one.)

1) Line 3 will not compile, because void methods cannot be overridden.
2) Line 8 will not compile, because there is no conversion of test() that
    takes a char argument.
3) The code will compile and produce the follwing output "int version"//
4) The code will compile and produce the follwing output "String version"

Question Number 39

Which of the following most closely describes the process of overriding?

1) A class with the same name replaces the functionality of a class defined
   earlier in the hierarchy
2) A method with the same name completely replaces the functionality of a
    method earlier in the hierarchy//
3) A method with the same name but different parameters gives multiple uses
   for the same method name
4) A class is prevented from accessing methods in its immediate ancestor

Question Number 40

Given the following code what will be output?

public class Pass{
static int j=20;
public static void main(String argv[]){
       int i=10;
       Pass p = new Pass();
       p.amethod(i);
       System.out.println(i);
       System.out.println(j);
       }
       public void amethod(int x){
       x=x*2;
       j=j*2;
       }
}

1) Error: amethod parameter does not match variable
2) 20 and 40
3) 10 and 40//
4) 10, and 20

Question Number 41

1. public class OuterClass {
2. private double d1 = 1.0;
3. //insert code here
4. }

You need to insert an inner class declaration at line 3. Which two inner class
declarations are valid?(Choose two.)

1. class InnerOne{
public static double methoda() {return d1;}
}

2. public class InnerOne{
static double methoda() {return d1;}
}

3. private class InnerOne{
double methoda() {return d1;}//
}

4. static class InnerOne{
protected double methoda() {return d1;}
}

5. abstract class InnerOne{
public abstract double methoda();//
}

Question Number 42

What will happen when you attempt to compile and run the following code

class Base{
private void amethod(int iBase){
       System.out.println("Base.amethod");
       }
}

class Over extends Base{


public static void main(String argv[]){
       Over o = new Over();
       int iBase=0;
       o.amethod(iBase);
       }
       public void amethod(int iOver){
               System.out.println("Over.amethod");
       }
}

1) Compile time error complaining that Base.amethod is private
2) Runtime error complaining that Base.amethod is private
3) Output of "Base.amethod"
4) Output of "Over.amethod"//

Question Number 43

What will appear in the standard output when you run the Tester class?

1.   class Tester {
2.     int var;

3.     Tester(double var) {
4.       this.var = (int)var;
5.     }

6.     Tester(int var) {
7.       this("hello");
8.     }

9.     Tester(String s) {
10.       this();
11.       System.out.println(s);
12.     }

13.     Tester() {
14.       System.out.println("good-bye");
15.     }

16.     public static void main(String args[]) {
17.       Tester t = new Tester(5);
18.     }

1) "hello"
2) 5
3) "hello" followed by "good-bye"
4) "good-bye" followed by "hello"//

Question Number 44

Which of the following statements are true about a variable created with the static modifier?

1) Once assigned the value of a static variable may not be altered
2) A static variable created in a method will keep the same value between calls
3) Only one instance of a static variable will exist for any amount of class instances//
4) The static modifier can only be applied to a primitive value

Question Number 45
Given the following class definition

public class Droitwich{
     class one{
             private class two{
                     public void main(){
                     System.out.println("two");
                     }
             }
     }
}


Which of the following statements are true


1) The code will not compile because the classes are nested to more than one level
2) The code will not compile because class two is marked as private
3) The code will compile and output the string two at runtime
4) The code will compile without error//

Question Number 46

Given the following code how could you invoke the Base constructor that will
print out the string "base constructor";

class Base{
       Base(int i){
       System.out.println("base constructor");
       }
       Base(){
       }
}

public class Sup extends Base{
       public static void main(String argv[]){
            Sup s= new Sup();
       //One
       }
       Sup()
       {
           //Two
       }
       public void derived()
       {
           //Three
       }
}

1) On the line After //One put Base(10);
2) On the line After //One put super(10);
3) On the line After //Two put super(10);//
4) On the line After //Three put super(10);

Question Number 47

Given the following class definition, which of the following methods could be legally
placed after the comment ?

public class Test{
       public void amethod(int i, String s){}

       //Here
}

1) public void amethod(String s, int i){}//
2) public int amethod(int i, String s){}
3) public void amethod(int i, String mystring){}
4) public void Amethod(int i, String s) {}//

Question Number 48

How can you implement encapsulation.

1) By making methods private and variable private
2) By making methods are public and variables as private//
3) Make all variable are public and access them using methods
4) Making all methods and variables as protected.

Question Number 49

What will happen when you attempt to compile and run this code?

private class Base{}
public class Vis{
     transient int  iVal;
     public static void main(String elephant[]){
       }
}

1)Compile time error: Base cannot be private//
2)Compile time error indicating that an integer cannot be transient
3)Compile time error transient not a data type
4)Compile time error malformed main method

Question Number 50

Which of the following statements are true?

1) A method cannot be overloaded to be less public in a child class
2) To be overridden a method must have the same name and parameter types
3) To be overridden a method must have the same name, parameter and return types//
4) An overridden method must have the same name, parameter names and parameter types

Edit: Added code tags and notice for long topic.  - Hostile
Actus non facit reum nisi mens sit rea

Adron

Some code tags and other markup could make this test much easier to read?

iago

Quote from: Adron on November 22, 2003, 06:25 AM
Some code tags and other markup could make this test much easier to read?

I was going to say the exact same thing :)
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Denial

there its fixed by a anonomous source now its easier to read
Actus non facit reum nisi mens sit rea

iago

Not really; the indents are still gone because it wasn't originally coded.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Hostile

Quote from: iago on November 22, 2003, 04:43 PM
Not really; the indents are still gone because it wasn't originally coded.

Didn't feel like fixing every single thing wrong with it.
- Hostile is sexy.

iago

Quote from: Hostile on November 22, 2003, 05:23 PM
Quote from: iago on November 22, 2003, 04:43 PM
Not really; the indents are still gone because it wasn't originally coded.

Didn't feel like fixing every single thing wrong with it.

lol, I don't blame you :)
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Denial

well sorry?! next time ill make it perfect for you
Actus non facit reum nisi mens sit rea

iago

Quote from: Denial on November 23, 2003, 01:27 AM
well sorry?! next time ill make it perfect for you

See that you do. :P
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Denial

Quote from: iago on November 23, 2003, 07:21 AM
Quote from: Denial on November 23, 2003, 01:27 AM
well sorry?! next time ill make it perfect for you

See that you do. :P


Money = Perfection Pay me and i will
Actus non facit reum nisi mens sit rea

iago

Quote from: Denial on November 23, 2003, 07:22 AM
Quote from: iago on November 23, 2003, 07:21 AM
Quote from: Denial on November 23, 2003, 01:27 AM
well sorry?! next time ill make it perfect for you

See that you do. :P


Money = Perfection Pay me and i will

It's too late, you already said you will! Next you post that quiz, I expect it to be perfect!
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*