GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

GradePack

What is the output of the following code? int num1 = 20;int…

What is the output of the following code? int num1 = 20;int num2 = 100;if (num2 < num1)    if (num2 > 50)        System.out.println(“foo”);else     System.out.println(“bar”);

Read Details

Write an equivalent lambda expression that implements the fu…

Write an equivalent lambda expression that implements the functional interface NE that could be used to replace the anonymous inner class given below. An example inner anonymous class implementation is given below. The body of the implementation must match the implementation given. Note: you only need to write the lambda expression NOT the entire block of code below. public class RunningOutOfIdeas{ public static void main(String[] args) { RunningOutOfIdeas rooi = new RunningOutOfIdeas(); rooi.test(new NE() { public boolean ne(double d1, double d2) { return Math.abs(d1-d2) > 0.001; } }); } public void test(NE nEq) { nEq.ne(1.331, 1.332); }}interface NE { public boolean ne(double d1, double d2);} Make sure to select the ‘Preformatted’ style from the dropdown so your code is formatted clearly. DO NOT USE THE TAB KEY WHEN WRITING CODE AS YOU MAY ACCIDENTALLY SUBMIT YOUR EXAM. USE THE SPACE BAR INSTEAD.

Read Details

Given the code below, what will be the value returned from t…

Given the code below, what will be the value returned from the method invocation shown? public static int mystery(int a, int b) {   if (a == 5 || b == 5) {        return 1;    } else {       return b + mystery(a / 5, b * 2);    }} int value = mystery(625, 2);

Read Details

Given the code below, what will be the value returned from t…

Given the code below, what will be the value returned from the method invocation shown? public static int mystery(int num1, int num2) {   if (num1 == 1 || num2 == 1) {        return 1;    } else {       return num2 + mystery(num1 / 3, num2 + 1);    }} int value = mystery(27, 7);

Read Details

Match the literals to their respective data types

Match the literals to their respective data types

Read Details

Given the code, is OutOfAir a checked or unchecked exception…

Given the code, is OutOfAir a checked or unchecked exception? Is IncorrectPart a checked or unchecked exception?  OutOfAir : [Item1] IncorrectPart : [Item2] class OutOfAir extends RuntimeException {   public OutOfAir(String msg) {       super(msg);     }  }  class IncorrectPart extends Exception {   public IncorrectPart(String msg) {       super(msg);     } } 

Read Details

Compile-time errors occur when there are syntax errors in th…

Compile-time errors occur when there are syntax errors in the source code.

Read Details

Given the following code, what is the value of b? String s1…

Given the following code, what is the value of b? String s1 = “CLOWNSHOES”;String s2 = “clownshoes”;s1 = s1.toLowerCase();boolean b = (s1 == s2);

Read Details

Given the class below, correctly override Object’s equals me…

Given the class below, correctly override Object’s equals method in this class, ensuring that it compares the full state of the object (i.e. the values of all data fields).Include the method header, curly braces, and implementation in your response. public class Car {     private String make;     private double mileage;     /* assume a valid constructor exists */     /* YOUR equals METHOD HERE */ }  Make sure to select the ‘Preformatted’ style from the dropdown so your code is formatted clearly. DO NOT USE THE TAB KEY WHEN WRITING CODE AS YOU MAY ACCIDENTALLY SUBMIT YOUR EXAM. USE THE SPACE BAR INSTEAD.

Read Details

What is the resulting value of the following expression: 7 /…

What is the resulting value of the following expression: 7 / 2 – 3 * 3 + 6

Read Details

Posts pagination

Newer posts 1 … 62,498 62,499 62,500 62,501 62,502 … 69,107 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top