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);
}
}
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
}
}
public class Test {
Test() { } // line 1
static void Test() { this(); } // line 2
public static void main(String[] args) { // line 3
Test(); // line 4
}
}
33. What will be the return type of a method that not returns any value?
34. Which of the following options is the best for generating random integer 0 or 1?
35. What is Math.floor(3.6)?
36. In which area of memory, the system stores parameters and local variables whenever a method is invoked?
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);
}
}
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();
}
}
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();
}
}
39. Which of the modifier can't be used for constructors?
40. The variables declared in a class for the use of all methods of the class are called
Read More Section(Constructors and Methods)
Each Section contains maximum 100 MCQs question on Constructors and Methods. To get more questions visit other sections.