GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

GradePack

Given the following code snippet: String[] animals = {“cat”,…

Given the following code snippet: String[] animals = {“cat”, “elephant”, “dog”, “giraffe”, “zebra”};String selectedAnimal = animals[0];int maxLength = animals[0].length(); for (String anAnimal : animals) {    if (anAnimal.length() > maxLength) {        maxLength = anAnimal.length();        selectedAnimal = anAnimal;    }} System.out.println(selectedAnimal + ” ” + maxLength);     What is the output of this code?

Read Details

We have defined an overloaded method called printName with 3…

We have defined an overloaded method called printName with 3 different versions.  Decide which version will be called by the following statement so you can predict what the output will be:                                                             printName(“Ana”, 210); public static void printName(String name, int id) { System.out.print(name + ” ID: ” + id);} public static void printName(int id) { System.out.print(“Name” + ” ID: ” + id);} public static void printName(String name, int id, int age) { System.out.print(name + ” ID: ” + id + ” age: ” + age);}  

Read Details

Given that the integer array y has elements {10, 20, 30, 40,…

Given that the integer array y has elements {10, 20, 30, 40, 50}, what is the output from the following loop? int j; for (j = 0; j < 4; ++j) {    System.out.print(y[j] + y[j + 1] + " ");}

Read Details

Which of the following if statements correctly checks if a v…

Which of the following if statements correctly checks if a variable age is between 18 and 25 (inclusive) or if age is greater than 65?

Read Details

What does the following UML diagram entry mean? – setHeight…

What does the following UML diagram entry mean? – setHeight (h : double) : int

Read Details

What is the value of x after this code executes? int x = 1;i…

What is the value of x after this code executes? int x = 1;int y = 2;int z = 3; x = z * x + y + z;     x = 1 + x++;    

Read Details

What is the primary purpose of the Eclipse debugger?

What is the primary purpose of the Eclipse debugger?

Read Details

Which if statement checks if a variable score is less than 5…

Which if statement checks if a variable score is less than 50 or greater than or equal to 90?

Read Details

What will the following code output if the variable score is…

What will the following code output if the variable score is set to 75? if (marks >= 90) {    System.out.println(“A”);} else if (marks >= 80) {    if (marks > 85 && marks < 90) {        System.out.println("B+");    } else {        System.out.println("B");    }} else if (marks >= 70) {    if (marks >= 75) {        System.out.println(“C+”);    } else {        System.out.println(“C”);    }} else {    System.out.println(“D or lower”);}

Read Details

For the given program, how many times will the println metho…

For the given program, how many times will the println method be executed?   public class ShippingController {     //——————————————     public static void main(String[] args){         printShippingCost(8);        printShippingCost(18);        printShippingCost(25);            }//end main        //——————————————     public static void printShippingCost(double weight) {         if((weight > 0.0) && (weight 5.0) && (weight 10.0) && (weight

Read Details

Posts pagination

Newer posts 1 … 44,987 44,988 44,989 44,990 44,991 … 80,950 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top