
int y = (int) y;
int x = y;
<h2><u>Hope</u><u> </u><u>it</u><u> </u><u>helps</u><u>.</u><u>.</u><u>♪</u></h2>
Answer:
Here is the constructor:
public Square(double s)
{ //constructor name is same as class name
sideLength = s; } //s copied into sideLength field
Explanation:
The above constructor is a parameterized constructor which takes a double type variable s as argument. The name of constructor is same as the name of class.This constructor requires one parameters. This means that all declarations of Square objects must pass one argument to the Square() constructor as constructor Square() is called based on the number and types of the arguments passed and the argument passed should be one and of type double.
Here is where the constructor fits:
public class Square {
private double sideLength;
public Square(double s)
{
sideLength = s; }
public double getArea() {
return sideLength * sideLength;}
public double getSideLength() {
return sideLength; } }
Huh???????................
Answer:
This statement is correct.
Explanation:
If a function does not have any parameters, then we can create the variable inside the function which will be private and call the function from the main function.
If we specify any return type like int, float or char, etc then we need to declare a return value from the function.
But If we specify the Void then we don't need to return value inside the function, we can directly print the value inside function.
Ex.
void add()
{
int a=7;
int b=9;
int c=a+b;
System.out.println("the added value is :"+c);
}