41.
Determine output of the following program.
public class Test{
           public static void main(String args[]){
                  System.out.println( Math.floor( Math.random( ) ) ) ;
           }
}

42.
What is the output of the above program?
class Num  {
      Num(double x ){
              System.out.println( x ) ;
      }   
}
public class  Test  extends  Num   {
       public static void main(String[] args){
                  Num num = new Num( 2 ) ;
       }     
}

43.
Determine Output:
class A{
	public static void method(int i){
		System.out.print("Method 1");
	}

	public static int method(String str){
		System.out.print("Method 2");
		return 0;
	}
}

public class Test{
     
	public static void main(String args[]){
		A.method(5);
	}
}

44.
What is the output of the program?
class Test{ 
        public int display(int x, int y){ 
                return ("The sum of x and y is " + x + y); 
        } 

        public static void main(String args[]){ 
                Test test = new Test();
                System.out.println(test.display(4,5)); 
        } 
}

46.
The finalize() method is called just prior to

47.
The main method should be static for the reason

48.
Given the following piece of code:
class Person{
        public int number;
}
public class Test{
        public void doIt(int i , Person p){
                i = 5;
                p.number = 8;
        }
        public static void main(String args[]){
                int x = 0;
                Person p = new Person();
                new Test().doIt(x, p);
                System.out.println(x + " " + p.number);
        }
}

What is the result?

49.
Which of the following statements regarding static methods are correct?
1. Static methods are difficult to maintain, because you can not change their implementation.
2. Static methods can be called using an object reference to an object of the class in which this method is defined.
3. Static methods are always public, because they are defined at class-level.
4. Static methods do not have direct access to non-static methods which are defined inside the same class.

50.
What is the prototype of the default constructor?
public class Test { }

Read More Section(Constructors and Methods)

Each Section contains maximum 100 MCQs question on Constructors and Methods. To get more questions visit other sections.