"मैं देख सकता हूँ कि आप पहले ही आराम कर चुके हैं। बहुत बढ़िया! यहाँ कंस्ट्रक्टर बनाने का अभ्यास करने के लिए कुछ कार्य दिए गए हैं:"
2
टास्क
Java Syntax, स्तर 5, सबक 9
You can't buy friends
In English, "to make friends" simply means "to get to know someone else and establish a friendship". It doesn't make to "make" or "create" someone. But I must say, it does sound like something is being built. Let's take this idiom from English into Java: We'll make a Friend class with three constructors. The first constructor will take a name. The second will also take an age. And the third will also take a gender.
4
टास्क
Java Syntax, स्तर 5, सबक 9
Creating cats
Create valid cats in an unnatural way: using constructors. Let's create a Cat class and declare five different constructors. The simplest constructor contains one parameter: name. The next has name and age. And we'll add weight to the third. Read about the rest in the task conditions.
2
टास्क
Java Syntax, स्तर 5, सबक 9
Dog registration
Tarantino Mad Dog Sanatorium accepts all breeds and colors of dogs for two-week vacations. Registration is open until November 2, 3126. Fill out one of the following three questionnaires: attentive owners indicate the name, height, and color of the pet; less attentive owners — the name and height; those with their heads in the ground — only the name. Create the Dog class and three constructors for registration.
2
टास्क
Java Syntax, स्तर 5, सबक 9
Walking in circles
If we need a circle to calculate a circumference, then we need a radius, or for analytical geometry — a radius and center, and for displaying a circle on the screen — preferably a color as well. What we're getting at is that we need to create a Circle class and create three different constructors for it.
2
टास्क
Java Syntax, स्तर 5, सबक 9
Create a Rectangle class
Before creating a class, you need to think about what it's for in order to choose and declare the appropriate fields, methods, and constructors. Let's create a "rectangle" class with the fields top, left, height, and width. And then we'll declare as many constructors as possible.
4
टास्क
Java Syntax, स्तर 5, सबक 9
Calling a constructor from a constructor
Calling a constructor from another constructor is quite natural, though to you it may currently seem like a complicated acrobatic feat. Carefully study the program, understand what it does, and fix the constructor with two parameters so that it calls another constructor with a radius of 10. Which one? Guess!)
2
टास्क
Java Syntax, स्तर 5, सबक 9
Max constructors
Your mentors at the secret CodeGym center have tried to prepare a Circle class for you. But this circle needs to be improved, and that is your task. Study the Circle class and, without changing anything else about the class, write the maximum number of possible constructors with different parameters. And don't forget about the default constructor.
4
टास्क
Java Syntax, स्तर 5, सबक 9
Constructor
How do you like figuring out someone else's code and finding bugs? Whatever your answer to this question, you can't get by without doing this. The best way to survive in the programming world is to love it. So, here's a program. Figure out what it does, and then find and fix the bug. In this case, the main method is untouchable (cannot be changed).
2
टास्क
Java Syntax, स्तर 5, सबक 9
The basis of a wheel
The wheel is based on the circle. To some extent, it has already been created, but the Circle class lacks a constructor (it only has the default constructor). In this task, you need to create a new constructor for Circle, which will initialize all instance variables (the constructor must have three parameters).