Question 3 What happens when a Java class does not have a programmer supplied constructor? A default constructor is supplied by the compiler that only creates null objects. A default constructor is supplied by the compiler that initialises all object variables to the system defined default value. No objects of this class can be created. A ConstructorNotFoundException is generated by the compiler.
Added by Jorge J.
Close
Step 1
Step 1: When a Java class does not have a programmer-supplied constructor, the compiler automatically provides a default constructor. Show more…
Show all steps
Your feedback will help us improve your experience
Akash M and 88 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Which of the following are true about the default constructor? 1. It is the only way to create an object from a class. 2. It must be defined in the class body. 3. It doesn't have any parameters. 4. It sets the class' reference variables to a default value defined by the programmer. 5. It sets integer fields to 0.
Akash M.
Which of the following statements are incorrect? a) The default constructor is called at the time of declaration of the object if a constructor has not been defined. b) A constructor can be parameterized. c) The finalize() method is called when an object goes out of scope and is no longer needed. d) The finalize() method must be declared protected. 6. What is the output of this program? class overload { int x; int y; int add(int a) { x = a + 1; } int add(int a, int b) { x = a + 2; } } class Overload_methods { public static void main(String args[]) { overload obj = new overload(); int a = 0; obj.add(6); System.out.println(obj.x); } } a) 5 b) 6 c) 7 d) 8
Sri K.
'What are difference between constructor and method in java? Ans:'
Florencia C.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD