Sail E0 Webinar

MCQs

Total Questions : 30 | Page 1 of 3 pages
Question 1. The following code contains one compilation error, find it?public class Test {Test() { } // line 1static void Test() { this(); } // line 2 public static void main(String[] args) { // line 3Test(); // line 4}}
  1.    At line 2, constructor call
  2.    At line 3, compilation error, ambiguity problem, compiler can't determine whether a constructor
  3.    At line 4
  4.    At line 1, constructor Tester must be marked public like its class
 Discuss Question
Answer: Option A. -> At line 2, constructor call
Question 2. What is Math.floor(3.6)?
  1.    4
  2.    4.0
  3.    3.0
  4.    3
 Discuss Question
Answer: Option D. -> 3
Question 3. What will be the return type of a method that not returns any value?
  1.    double
  2.    void
  3.    None of these
  4.    int
 Discuss Question
Answer: Option B. -> void
Question 4. 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); }}
  1.    50
  2.    10 50
  3.    Won't compile because of line (1), constructor can't be private
  4.    Won't compile because of line (5), constructor can't be static
 Discuss Question
Answer: Option D. -> Won't compile because of line (5), constructor can't be static
Question 5. Which of the following options is the best for generating random integer 0 or 1?
  1.    (int)Math.random()
  2.    (int)(Math.random() + 0.5)
  3.    (int)Math.random() + 1
  4.    (int)(Math.random() + 0.2)
 Discuss Question
Answer: Option B. -> (int)(Math.random() + 0.5)
Question 6. What is the expected output?public class Profile {private Profile(int w) { // line 1System.out.print(w);}public final Profile() { // line 5System.out.print(10);}public static void main(String args[]) {Profile obj = new Profile(50);}}
  1.    Won't compile because of line (5); constructor can't be final
  2.    Won't compile because of line (1); constructor can't be private
  3.    10 50
  4.    50
 Discuss Question
Answer: Option A. -> Won't compile because of line (5); constructor can't be final
Question 7. In which area of memory, the system stores parameters and local variables whenever a method is invoked?
  1.    Storage Area
  2.    Array
  3.    Heap
  4.    Stack
 Discuss Question
Answer: Option D. -> Stack
Question 8. The variables declared in a class for the use of all methods of the class are called
  1.    instance variables
  2.    reference variables
  3.    objects
  4.    None of these
 Discuss Question
Answer: Option A. -> instance variables
Question 9. Which of the modifier can't be used for constructors?
  1.    protected
  2.    public
  3.    static
  4.    private
 Discuss Question
Answer: Option C. -> static
Question 10. 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();}}
  1.    Wild Animal
  2.    Compilation Error
  3.    Runtime Exception
  4.    Animal Wild
 Discuss Question
Answer: Option B. -> Compilation Error

Latest Videos

Latest Test Papers