1. Which three statements are true? The default constructor initialises method variables. The default constructor has the same access as its class. The default constructor invokes the no-arg constructor of the superclass. If a class lacks a no-arg constructor, the compiler always creates a default constructor. The compiler creates a default constructor only when there are no other constructors for the class.





Ask Your Doubts Here

Type in
(Press Ctrl+g to toggle between English and the chosen language)

Comments

  • By: guest on 02 Jun 2017 01.25 am
    (2) sounds correct as in the example below class CoffeeCup { private int innerCoffee; public CoffeeCup() { } public void add(int amount) { innerCoffee += amount; } //... } The compiler gives default constructors the same access level as their class. In the example above, class CoffeeCup is public, so the default constructor is public. If CoffeeCup had been given package access, the default constructor would be given package access as well. (3) is correct. The Java compiler generates at least one instance initialisation method for every class it compiles. In the Java class file, the instance initialisation method is named "<init>." For each constructor in the source code of a class, the Java compiler generates one <init>() method. If the class declares no constructors explicitly, the compiler generates a default no-arg constructor that just invokes the superclass's no-arg constructor. As with any other constructor, the compiler creates an <init>() method in the class file that corresponds to this default constructor. (5) is correct. The compiler creates a default constructor if you do not declare any constructors in your class.
Show Similar Question And Answers
QA->Two statements are given followed by two conclusions I and II. You have to consider the two statements to be true even if they seem to be at variance from commonly known facts. You have to decide which one of the given conclusions is definitely drawn from the given statements. Statement : All virtuous persons are happy. No unhappy person is virtuous. Conclusions : I. Happiness is related to virtue II. Unhappy person is not virtuous.....
QA->There are 50 students in a class. In a class test 22 students get 25 marks each, 18 students get 30 marks each. Each of the remaining gets 16 marks. The average mark of the whole class is :....
QA->.In the question below three words are given.They are followed by four words one of which stands for the class to which these three words belong.Identify that word:Barbarous,Crude,Rude....
QA->“One caste, One religion and One God for man of the same blood and form, there is no difference animals of the same caste alone procreate Viewed thus all humanity belong to one caste”- In which book of Sree Narayana Guru these words can be seen?....
QA->Giridharlal’s family consists of his wife Radha. 3 sons and 2 daughters. One daughter is yet to be married and the other daughter has a son. Two sons have 2 children each and the third son has 3 children. An old aunt and sonin-law also stay with them. How many members are there in Giridharlal’s family ?....
MCQ->Which three statements are true? The default constructor initialises method variables. The default constructor has the same access as its class. The default constructor invokes the no-arg constructor of the superclass. If a class lacks a no-arg constructor, the compiler always creates a default constructor. The compiler creates a default constructor only when there are no other constructors for the class.....
MCQ->Which of the following statements are correct about constructors in C#.NET? Constructors cannot be overloaded. Constructors always have the name same as the name of the class. Constructors are never called explicitly. Constructors never return any value. Constructors allocate space for the object in memory.....
MCQ->Which of the following rules are used in choosing the repeating variables in dimensional analysis : 1. Repeating variables should include the dependent variables 2. Repeating variables should contain all primary units used in describing the variables in the problem 3. Repeating variables should combine among themselves. 4. Repeating variables should not contain the dependent variables. Select the correct answer using the codes given below :....
MCQ->Which two statements are true about comparing two instances of the same class, given that the equals() and hashCode() methods have been properly overridden? If the equals() method returns true, the hashCode() comparison == must return true. If the equals() method returns false, the hashCode() comparison != must return true. If the hashCode() comparison == returns true, the equals() method must return true. If the hashCode() comparison == returns true, the equals() method might return true.....
MCQ->Which two statements are true about wrapper or String classes? If x and y refer to instances of different wrapper classes, then the fragment x.equals(y) will cause a compiler failure. If x and y refer to instances of different wrapper classes, then x == y can sometimes be true. If x and y are String references and if x.equals(y) is true, then x == y is true. If x, y, and z refer to instances of wrapper classes and x.equals(y) is true, and y.equals(z) is true, then z.equals(x) will always be true. If x and y are String references and x == y is true, then y.equals(x) will be true.....
Terms And Service:We do not guarantee the accuracy of available data ..We Provide Information On Public Data.. Please consult an expert before using this data for commercial or personal use | Powered By:Omega Web Solutions
© 2002-2017 Omega Education PVT LTD...Privacy | Terms And Conditions
Question ANSWER With Solution