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
Answer #1

Sign Up to Unlock the answer FREE

Already have an account? Log in

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
  • need code to copy and output //Exercise07_02 // Exercise07_02.java: Enter 10 integers and // display the...

    need code to copy and output //Exercise07_02 // Exercise07_02.java: Enter 10 integers and // display the numbers in reverse order public class Exercise07_02 { public static void main (String[] args) { java.util.Scanner input = new java.util.Scanner(System.in); int[] num = new int[10]; for (int i = 0; i <10; i++) { // Read a number System.out.print( "Read a number: "); num[i] = input.nextInt(); } // Display the array reversely System.out.print("The reversal of the input is "); for (int i = 9;...

  • 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...

  • 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...

  • 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),...

  • 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();   ...

  • 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) {...

  • 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;...

  • 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...

  • Complete the code below, test cases to use are at the bottom package Labs; public class ResizingQ...

    Complete the code below, test cases to use are at the bottom package Labs; public class ResizingQueue { private final int INITIAL_SIZE = 10;   private int [] A = new int[INITIAL_SIZE]; // array to hold queue: front is always at Q[0] // and rear at A[next-1] int next = 0; // location of next available unused slot // interface methods public void enqueue(int key) { //TODO: push the key onto the back of the queue // YOUR CODE HERE! }...

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