By default, if you do not implement a constructor, the compiler will use an empty constructor (no parameters and no code). The following code will create an instance of the MyObject class using the default constructor. The object will have the default vauesfor all the attributes since no parameters were given.
MyObject obj = new MyObject();
Another type of constructor is one with no parameters (no-arg constructor). It is similar to the default, except you actually create this constructor. The contents of the the constructor may include anything. To call a no-arg constructor, use the same line of code as above. The constructor can look like the one below:
public MyObject() {
System.out.println("This is a no-arg constructor");
}
Lastly there is the parameterized constructor. This type of constructor takes in parameters as inputs to assign to values in the newly created object. You call a parameterized constructor as follows:
MyObject obj = new MyObject("Bob", 20);
The constructor will look like this:
public MyObject(String name, int age) {
this.name = name;
this.age = age;
}
In the constructor, the keyword "this" refers to the object, so this.name is a private global variable that is being set equal to the inputted value for name, in this case "Bob".
Hope this helps!
Answer:
B is the answer.. pls mark me as brainliest
ctrl+shift+down arrow
Explanation:
Answer:
b. the same data type
Explanation:
Any number of variables can be declared in a statement as long as the variables have the same data type. For example:
1) int a,b,c,d,e;
Here each of the declared variables a,b,c,d,e have the type int.
2) char p,q,r,s,t,u,v,w;
In this case variables p to w all have the type char.
3) float x,y,z;
x,y and z are all of type float.
Answer:
Answer is:
Client-Server Network
- expensive to set up
- has a central server
- easy to track files
- useful for a large organization
Peer-to-peer Network
- useful for a small organization
- difficult to track files
- inexpensive to set up
- does not have a central server
Explanation:
<em>Client-Server Network is ideal for bigger network set up like offices and companies where there will be a central server involved with several clients to access and connected with the server. This is the normal network set up to companies. While, Peer to peer network is ideal for much smaller network, which consists of only two computers to communicate and share files. This network is normally temporary and inexpensive since in only works with two computers.</em>