0
Alien head

programming languages Online Quiz - 207

Description: programming languages Online Quiz - 207
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0

Given: class Titanic { public static void main(String[] args) { Boolean bl = true; boolean b2 = false; boolean b3 = true; if((bl & b2) | (b2 & b3) & b3) System.out.print("alpha "); if((bl = false) | (b1 & b3) | (bl | b2)) System.out.print("beta "}; } } What is the result?

  1. beta

  2. alpha

  3. alpha beta

  4. Compilation fails

  5. No output is produced

  6. An exception is thrown at runtime


Correct Option: E

Given: class Foozit { public static void main(String[] args) { Integer x = 0; Integer y = 0; for(Short z = 0; z < 5; z++) if((++x > 2) || (++y > 2)) X++ ; System.out.println(x + " " + y); } } What is the result?

  1. 5 1

  2. 5 2

  3. 5 3

  4. 8 1

  5. 8 2

  6. 8 3


Correct Option: E

class Fork { public static void main(String[] args) { if(args.length == 1 | args[1] .equals("test")) { System.out.println ("test case"); } else { System.out.println("production " + args[0]); } }}And the command-line invocation:java Fork live2What is the result?

  1. test case

  2. production

  3. test case live2

  4. Compilation fails

  5. An exception is thrown at runtime


Correct Option: E

Given: class Hexy { public static void main(String[] args) { Integer i = 42; String s = (i<40)?"life":(i>50)?"universe":"everything"; System.out.println(s); } } What is the result?

  1. null

  2. life

  3. universe

  4. everything

  5. Compilation fails

  6. An exception is thrown at runtime


Correct Option: D

What does AWT stands for ?

  1. Advanced Window Toolkit

  2. Abstract window Toolkit

  3. Adjust Window Toolkit

  4. None of these


Correct Option: B

What is the difference between private and public functions ?

  1. Public functions are free, you have to buy private ones

  2. Public functions are the only ones you can download

  3. Public functions can be used by anyone, private can only be used by other code in the class you are writing

  4. Public functions can’t be used


Correct Option: C

What is a function in terms of Computer Science ?

  1. A group of code lines that performs a specific task

  2. A group of code lines that performs a whole program

  3. Something that contains an ‘init’

  4. The purpose of Java


Correct Option: A

In a ‘for’ loop, what section of the loop is not included in the parentheses after “for” ?

  1. Initialization

  2. Loop Body

  3. Test statement

  4. Update


Correct Option: B

Which is NOT a section of all types of loops ?

  1. Initialization

  2. Loop Body

  3. Test statement

  4. The word "while"


Correct Option: D

What is essential in making sure that your loop is not infinite ?

  1. That there is a Boolean statement somewhere in your code

  2. That your Boolean statement will at some point be false

  3. That your Boolean statement will at some point be true

  4. All of the above


Correct Option: B

What is a loop ?

  1. A new type of Applet

  2. A segment of code to be run a specified amount of times

  3. A segment of code to be run infinite times

  4. A segment of code to be run once


Correct Option: B

Which of the following means that in order for the conditional to happen, either x must be less than 3 or y must be greater than or equal to 4 ?

  1. if ((x < 3) && (y > 4))

  2. if (x < 3 y >= 4)

  3. if ((x < 3) || (y > = 4))

  4. if ((x > 3) || (y < = 4))


Correct Option: C

If you want your conditional to depend on two conditions BOTH being true, what is the proper notation to put between the two Boolean statements ?

  1. &

  2. &&

  3. ||


Correct Option: B

What will be the value of “num” after the following statements? int num; num = (5+4); num = num / 9; num = 12;

  1. 0

  2. 1

  3. 12

  4. 9


Correct Option: C

What is an assignment statement ?

  1. Adding a number to an int

  2. Assigning a multiplication

  3. Assigning a name to a variable

  4. Assigning a value to a variable


Correct Option: D

The following statements make “length” be what number ? int length; length = 4; length ++;

  1. 4

  2. 5

  3. 6

  4. 8


Correct Option: B

Booleans are _______.

  1. True or False

  2. Single characters

  3. Text

  4. All numbers


Correct Option: A

What is the proper way to declare a variable ?

  1. variableName variableType;

  2. variableName;

  3. variableType;

  4. variableType variableName;


Correct Option: D

What is the main function of any variable ?

  1. To add numbers together

  2. To keep track of data in the memory of the computer

  3. To print words on the screen

  4. To write Java


Correct Option: B

What's the difference between an Applet and an application ?

  1. An application is only available on Windows

  2. Applets can paint words, applications cannot.

  3. Applets are run over the web.

  4. None of the above.


Correct Option: C
+ View questions