Question

1. What is the output? System.out.print(3 + 3 * 3); a. 18 b. 12 c. 9 d. 0 e. 10             2.   What is output by the code below? System.out.print("\\dog\\cat&#...

1. What is the output?

System.out.print(3 + 3 * 3);

a.

18

b.

12

c.

9

d.

0

e.

10

            2.   What is output by the code below?

System.out.print("\\dog\\cat");

a.

dog

b.

dogcat

c.

\\dog\\cat

d.

\dog\cat

e.

catdog\\\\

            3.   What is returned by the call     getIt(9) ?

public static int getIt(int num){

int ans = 0;

if( num >=2 )

{

     if( num >= 7)

        ans += 2;

     else

        ans += 3;

}

ans += 4;

return ans;

}

a.

4

b.

2

c.

6

d.

7

e.

9

            4.   What is returned by the call     getIt(3) ?

public static int getIt(int num)

{

int ans = 0;

if( num >=2 )

{

     if( num >= 7)

        ans += 2;

     else

        ans += 3;

}

ans += 4;

return ans;

}

a.

4

b.

6

c.

7

d.

4

e.

9

            5.   What is returned by the call     getIt(1) ?

public static int getIt(int num)

{

int ans = 0;

if( num >=2 )

{

     if( num >= 7)

        ans += 2;

}

else

{

     ans += 3;

}

   ans += 4;

return ans;

}

a.

4

b.

5

c.

6

d.

7

e.

9

              

            6.   What is output by the code below?

//client code

int[] list = {2,12,11,45,52,36,5,3,1};

System.out.println( go(list) );

//go receives an array and returns a calculated value

public static double go( int[] ray )

{

int val = 0;

for(int i=0; i < ray.length; i = i + 2)

    val = val + ray[i];

return val;

}

a.

45.0

b.

96.0

c.

56.0

d.

65.0

e.

71.0

            7.   What is output by the code below?

//client code

int[] list = {2,12,11,45,52,36};

System.out.println( go(list) );

//go receives an array and returns a calculated value

public static int go( int[] ray )

{

int val = Integer.MIN_VALUE;

for(int i=0; i < ray.length; i++)

    if( ray[i] > val )

      val = ray[i];

return val;

}

a.

45

b.

2

c.

12

d.

52

e.

36

              

            8.   What is the code shown below working to locate?

public static int go( int[] ray )

{

int val = Integer.MIN_VALUE;

for(int i=0; i < ray.length; i++)

    if( ray[i] > val )

      val = ray[i];

return val;

}

a.

The code is trying to locate all of the even numbers.

b.

The code is trying to locate the biggest number.

c.

The code is trying to locate the smallest number.

d.

The code is trying to locate all of the odd numbers.

e.

The code is trying to locate the biggest even number.

            9.   What is output by the code below?

//client code

int[] list = {3, 6, 9, 2, 4, 5};

System.out.println( go(list) );

//go receives an array and returns a calculated value

public static int go( int[] ray )

{

int val = 0;

for(int i=0; i < ray.length; i++)

    val = val + ray[i];

return val;

}

a.

29

b.

27

c.

20

d.

26

e.

25

          10.   What is output by the code below?

System.out.println(Math.pow(2,4));

a.

32

b.

16

c.

16.0

d.

32.0

e.

8.0

0 0
Add a comment Improve this question Transcribed image text
Answer #1

ANSWER:-

QUESTION (1):-

OPTION (B) 12

QUESTION (2):-

OPTION (D) \dog\cat


QUESTION (3):-

OPTION (C) 6

QUESTION (4):-

OPTION (E) 71.0

QUESTION (5):-

OPTION (D) 52

QUESTION (6):-

OPTION (B)

QUESTION (7):-

OPTION (A) 29

QUESTION (8):-

OPTION (C) 16.0

Add a comment
Know the answer?
Add Answer to:
1. What is the output? System.out.print(3 + 3 * 3); a. 18 b. 12 c. 9 d. 0 e. 10             2.   What is output by the code below? System.out.print("\\dog\\cat&#...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. What is the output when you run printIn()? public static void main(String[] args) { if...

    1. What is the output when you run printIn()? public static void main(String[] args) { if (true) { int num = 1; if (num > 0) { num++; } } int num = 1; addOne(num); num = num - 1 System.out.println(num); } public void addOne(int num) { num = num + 1; } 2. When creating an array for primitive data types, the default values are: a. Numeric type b. Char type c. Boolean type d. String type e. Float...

  • I have this code but when there's 0 pennies, it doesn't output "and 0 pennies" at...

    I have this code but when there's 0 pennies, it doesn't output "and 0 pennies" at all, it is just left blank. package edu.wit.cs.comp1050; /** * Solution to the third programming assignment * When it runs it outputs the amount in quarters, dimes, nickels and pennies * * @author Rose Levine * */ import java.util.Scanner; public class PA1c {       /**    * Error message to display for negative amount    */    public static final String ERR_MSG =...

  • java create java program that make stack with LinkedList and stack is implement iterator. When stack’s iterator call next(), it pop its data. here is the example of output //by user 5 1 2 3 4 5 //then...

    java create java program that make stack with LinkedList and stack is implement iterator. When stack’s iterator call next(), it pop its data. here is the example of output //by user 5 1 2 3 4 5 //then output comes like this 5 4 3 2 1 Stack is empty. here is the code that i'm going to use class Stack<T> implements Iterator<T> {    LinkedList<T> list;       public Stack() {        list = new LinkedList<T>();    }       public boolean isEmpty() {        return list.isEmpty();   ...

  • Please try to explain the answers as well. It will be highly appreciated. Output of the...

    Please try to explain the answers as well. It will be highly appreciated. Output of the following expression: 5 * 4 % 2 = ? Output of a loop: Example: What will be the output of the Java code (Assume all variables are properly declared.) num = 10; while (num <= 32)                 num = num + 5; System.out.println(num); What will be the output of the Java code (Assume all variables are properly declared.) public class test {   ...

  • 1. What is the output of the following code segment? int array[] = { 8, 6,...

    1. What is the output of the following code segment? int array[] = { 8, 6, 9, 7, 6, 4, 4, 5, 8, 10 }; System.out.println( "Index Value" ); for ( int i = 0; i < array.length; i++ ) System.out.printf( "%d %d\n", i, array[ i ] ); 2. What is the output of the following code segment? char sentence[] = {'H', 'o', 'w', ' ', 'a', 'r', 'e', ' ', 'y', 'o', 'u' }; String output = "The sentence...

  • c++ Consider the following C++ code: 7 string animals[5] = {"dog", "cat", "turkey", "shark", "lion"); B...

    c++ Consider the following C++ code: 7 string animals[5] = {"dog", "cat", "turkey", "shark", "lion"); B 9 void* printword(void* arg) 10 { 11 int id = *((int*) arg); 12 13 cout << "Current word: « animals[id] << endl; 15 pthread_exit(NULL); 16 } 17 18 int main() 19 { 20 pthread_t thread_id[5]; 21 22 for(int num = 0; num < 5; num++) 23 { 24 1/ pass the current value of id as a parameter to the new thread 25 pthread_create(&thread_id(num),...

  • Doubly Linked List The assignment is to modify the below code in any way (like changing the method of a function). Time...

    Doubly Linked List The assignment is to modify the below code in any way (like changing the method of a function). Time complexity is omitted. Any methods/functions below could be changed into something different. I was thinking of changing the method of getting size of list and maybe change from numbers to letters for nodes. import java.util.Scanner; /* Class Node */ class Node { protected int data; protected Node next, prev; /* Constructor */ public Node() { next = null;...

  • add/ remove any methods to the program. please post new code and output Min Heap: public...

    add/ remove any methods to the program. please post new code and output Min Heap: public class MinHeap { private int[] Heap; private int size; private int maxsize; private static final int FRONT = 1; public MinHeap(int maxsize) { this.maxsize = maxsize; this.size = 0; Heap = new int[this.maxsize + 1]; Heap[0] = Integer.MIN_VALUE; } private int parent(int pos) { return pos / 2; } private int leftChild(int pos) { return (2 * pos); } private int rightChild(int pos) {...

  • In this code I have 3 racers running, dog, cat, and tigger. Dog and tigger are...

    In this code I have 3 racers running, dog, cat, and tigger. Dog and tigger are at random speeds and the cat controlled by pressing a and s to move. Please just edit the code to include part E which is when one of the three racers reaches the finish line announce the winner. import java.awt.Color; import java.util.Random; public class RaceTrack{    public static void main(String[] args) {        //        EZ.initialize(680,680);        //        int...

  • NO ONE HAS PROVIDED THE CORRECT CODE TO PROVIDE THE GIVEN OUTPUT. PLEASE PROVIDE CODE THAT...

    NO ONE HAS PROVIDED THE CORRECT CODE TO PROVIDE THE GIVEN OUTPUT. PLEASE PROVIDE CODE THAT WOULD CAUSE THE HW1.java TO PRINT THE RIGHT DATA.!!! The LinkedList class implements both the List interface and the Stack interface, but several methods (listed below) are missing bodies. Write the code so it works correctly. You should submit one file, LinkedList.java. Do not change the interfaces. Do not change the public method headers. Do not rename the LinkedList class. None of your methods...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT