GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

Author Archives: Anonymous

Consider the following code segment. for (int j = 1; j < 10;...

Consider the following code segment. for (int j = 1; j < 10; j += 2){System.out.print(j);}   Which of the following code segments will produce the same output as the code segment above?

Read Details

Determine if the following evaluates to true or false based…

Determine if the following evaluates to true or false based on the value of these variables:   int a = 0;int b = 1;   !(a == 0 && b == 2);

Read Details

Consider the following information about the Person class….

Consider the following information about the Person class. The class has an int attribute age that represents a person’s age. The class has a non-static getAge method that has no parameters and returns the value of age. This method can be called from another class. The following code segments each appear in a class other than Person. Assume that p is a Person object whose age attribute is equal to 16. Code Segment 1 int val1 = p.getAge();System.out.println(val1);   Code Segment 2 int val2 = Person.getAge();System.out.println(val2);   What, if anything, is printed as a result of executing each of the code segments?

Read Details

Consider the following code segment. String one = “computer”…

Consider the following code segment. String one = “computer”; String two = “science”;String concat = /* missing code */; System.out.println(concat); Which of the following expressions can be used to replace /* missing code */ so that the code segment prints the string “pun”?

Read Details

What occurs when an integer expression evaluates to a value…

What occurs when an integer expression evaluates to a value outside the allowed range?

Read Details

Users of a mobile application are categorized based on the a…

Users of a mobile application are categorized based on the average number of hours they use the application each day, as shown in the following table.   Mobile Number Users Category Average Hours of Use Per Day Top User Greater than 5 Regular User Between 1 and 5, inclusive Inactive User Less than 1     Suppose n is the average number of hours a user spends using the application each day. Which of the following algorithms can be used to assign the correct categorization to a user?

Read Details

Consider the following code segment, which is intended to pr…

Consider the following code segment, which is intended to print true only when both r and v are positive numbers. Assume that r and v have been properly declared and initialized.   boolean rPos = r > 0; boolean vPos = v > 0;System.out.print(rPos == vPos);    The code segment does not always work as intended.   Which of the following values for r and v will demonstrate that this code segment does not work as intended?

Read Details

In the following code segment, n is a properly declared and…

In the following code segment, n is a properly declared and initialized int variable.     boolean result = false; if (n >= 10){ result = true;}if (n

Read Details

Consider the following code segment.   for (int m = 16; m >…

Consider the following code segment.   for (int m = 16; m > 0; m -= 2){ if ((m % 3) == 1) { System.out.print(m + ” “); }}   What is printed as a result of executing this code segment?

Read Details

What is the output of the following code segment?   for (int…

What is the output of the following code segment?   for (int k = 5;  k > -5; k–){  System.out.print( k + ” ” );}System.out.println( );

Read Details

Posts pagination

Newer posts 1 … 47 48 49 50 51 … 86,439 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top