4. Write an if/else statement in ternary format that compares the value of two int variables, firstNum and secondNum, and sets the value of an int variable minValue appropriately as follows: minValue should be the minimum of firstNum and secondNum.
5. Assume that Person is a predefined class and that the declaration Person[] people; has already been performed. Then the instruction
People = new Person [200];
Reserves memory space for(Circle the answer):
Option 1: a single Person object
Option 2: 200 Person objects
Option 3: a single reference variable that points to a single Person object
Option 4:200 reference variables and 200 Person objects
Option 5: 200 reference variable, each of which can point to a separate Person object
Option 6: a single reference variable to the memory that stores all 200 Person objects
6. Consider a method defined as follows:
Public void myMethod(double x, int y):
Circle which of the following method calls is legal? (zero, one, or more answers may be correct)
Option 1: myMethod();
Option 2: myMethod(-1);
Option 3: myMethod(7 * 3.0, 7 /14);
Option 4: myMethod(37, 0.5);
7. Given two String variables, string1 and string2, write a line of code that would determine if they have the same length
Dear Student ,
As per the requirement submitted above , kindly find the below solution.
Question 4:
Answer : minValue=(firstNum>secondNum)?secondNum:firstNum;
Explanation :Below screen shows the Java code for ternary operator.
*****************************
Question 6:
Answer : Option 3: myMethod(7 * 3.0, 7 /14);
Explanation :for myMethod(double,int) which calls myMethod(7 * 3.0, 7 /14);
*****************************
Question 7:
Explanation :Below code snippet gives the details
public class Main
{
public static void main(String[] args) {
//declaring strings
String string1="asdf",string2="pqrs";
//checking strings
if(string1.length()==string2.length())
{
System.out.println("Equal");//display equal
}
else{
System.out.println("Not Equal");//display not
equal
}
}
}
Output :
*****************************
NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.
4. Write an if/else statement in ternary format that compares the value of two int variables, firstNum and secondNum, and sets the value of an int variable minValue appropriately as follows: minValue...
4. Write an if/else statement in ternary format that compares the value of two int variables, firstNum and secondNum, and sets the value of an int variable minValue appropriately as follows: minValue should be the minimum of firstNum and secondNum. 5. Assume that Person is a predefined class and that the declaration Person[] people; has already been performed. Then the instruction People = new Person [200]; Reserves memory space for(Circle the answer): Option 1: a single Person object ...
5. Assume that Person is a predefined class and that the declaration Person[] people; has already been performed. Then the instruction People = new Person [200]; Reserves memory space for(Circle the answer): Option 1: a single Person object Option 2: 200 Person objects Option 3: a single reference variable that points to a single Person object Option 4:200 reference variables and 200 Person objects Option 5: 200 reference variable, each of which can point to...