31.
What is the expected output?
public class Profile {
         private Profile(int w) { // line 1
                  System.out.print(w);
         }
         public static Profile() { // line 5
                  System.out.print (10);
         }
         public static void main(String args[]) {
                  Profile obj = new Profile(50);
         }
}

32.
The following code contains one compilation error, find it?
public class Test {
	Test() {    }  // line 1
	static void Test() {  this(); } // line 2  
	public static void main(String[] args) { // line 3
		Test(); // line 4
	}
}

34.
Which of the following options is the best for generating random integer 0 or 1?

37.
What is the expected output?
public class Profile {
	private Profile(int w) { // line 1
		System.out.print(w);
	}
	public final Profile() { // line 5
		System.out.print(10);
	}
	public static void main(String args[]) {
		Profile obj = new Profile(50);
	}
}

38.
What is the expected output?
class Animal {
	Animal() {
		System.out.println("Animal");
	}
}
class Wild extends Animal{
	Wild() {
		System.out.println("Wild");
		super();
	}
}
public class Test {
	public static void main(String args[]) {
		Wild wild = new Wild();
	}
}

Read More Section(Constructors and Methods)

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