2.1_Creating Objects Flashcards

1
Q

How to declare variables in Java?

A

{Type} varName;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Where fields can be initialized?

A
Fields can be initialized: 
 o  Inline (At the same line of its declaration)
 o  or via Constructor
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the syntax to declare a Constructor?

A

o It should matches the class-name

o there’s 👀️⚠️NO return type⚠️👀️.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What could be called a fake Constructor?

A

🤯️⚠️ When you see a method name which matches the name of the class but ❌having a return type❌

🤯️📣️Pay special attention to it. It is not a constructor since there’s a return type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

When does the compiler provides the default constructor?

A

If no other constructors are available in the class, the compiler will supply a “do nothing” default constructor for you.
⚠️(There are some scenarios that do require you declare a constructor.)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly