CSC 1301
Add parentheses to the following expressions to indicate how Java will interpret them. a % b / c % d + e
((a % b) / c )% d + e
Add parentheses to the following expressions to indicate how Java will interpret them. a * b * c - d / e
((a * b) * c) - (d / e)
Add parentheses to the following expressions to indicate how Java will interpret them. a - b - c * d / e
(a -b) - ((c * d)/ e)
Add parentheses to the following expressions to indicate how Java will interpret them. a / b + c - d * e
(a / b) + c - (d * e)
What is the operator for multiplication in Java?
*
What is the operator for addition in Java?
+
What is the operator for subtraction in Java?
-
What is the value and parameter of the expression? 4 / 8 - 1.5 Value = ? , Type = ?
-1.5 , double
What is the value and the parameter of the expression? 43 + 75 % 12 - 68 Value = ? , Type = ?
-22 , int
What is the operator for division in Java?
/
What are the two ways to make a comment in Java?
// ; /* and */
What value is assigned to discount? double discount; char code = 'b'; switch ( code ) { case 'a': case 'A': discount = 0.0; break; case 'b': case B: discount = 0.1; break; case 'c': case 'C': discount = 0.2; break; default: discount = 0.3; }
0.1
Write 3/4 in binary, using a "floating binary point".?
0.11
What value is assigned to discount? double discount; char code ='c' ; switch ( code ) { case 'A': discount = 0.0; case 'B': discount = 0.1; case 'C': discount = 0.2; default: discount = 0.3; }
0.3
Translate 255_10 base 10 to Binary using 16 bits
0000000011111111
What is the value and the parameter of the expression? 7 % 2 + 9 /5 -1 Value = ? , Type = ?
1 , int
What is the output of this program? Please account for the " " = 1 space class increment { public static void main(String args[]) { double var1 = 1 + 5; double var2= var1 / 4; int var3 = 1 +5; int var4 = var3 / 4; System.out.print(var2 + " " + var4); } }
1.5 1
What is the output of this program class binary { public static void main(String args []){ int num= 17; System.out.println(Integer.toBinaryString(num)); }
10001
Convert the Hexadecimal value of A01C to binary
1010000000011100
Convert the Hexadecimal value of ABB to binary
101010111011
Convert Decimal number 90 to Binary
1011010
What will be the following output of the code? int x = 5; int y = 6; System.out.println(x + y);
11
Convert the binary number (01011.101) to decimal
11.625
Convert the decimal number 6.74 to binary
110.11
Convert Decimal number 122 to Binary:
1111010
How does one decorate a 31-year-old's birthday cake with only five candles?
11111
Convert Decimal number 62 to Binary
111110
If a CPU mad its calculations using a group of 4 bits together, we get a maximum value of ?
15
What will the output be for the following code? int myNum = 15; System.out.println(myNum);
15
Convert the decimal number 476 to hexadecimal
1DC
Given the following method which returns a value: public static double average(int num1, int num2, int num3) { return ( num1 + num2 + num3) / 3.0; } System.out.println(average(1,2,3)); Output: ?
2.0
What will the output be for the following code? int myNum = 15; myNum = 20; System.out.println(myNum);
20
10101
21
Convert the Binary number 11101001 to Decimal:
233
Convert the binary value of 1110 1110 to decimal
238
What will be the output of the following program? public class Doubt{ public static void main(String[]){ int x = 20; int y = 25; if(++x < (y= y-=4) || (x= x+= 4) > y){ System.out.println(x+","+y); } } }
25,21
If we increase the numbers of bits the CPU uses to a grouping of 8 bits, we get a maximum value of ?
255
What will the output be for the following code? int myNum; myNum = 26; System.out.println(myNum);
26
Given the following method which returns a value: public static double average(int num1, int num2, int num3) { return ( num1 + num2 + num3) / 3.0; } System.out.println(average((1 + 2), (2 + 2), (2 + 3))); Output: ?
4.0
What is the value of sum2 and sum3 int sum1 = 100 + 50; int sum2 = sum1 + 250; int sum3 = sum2 + sum2;
400 ; 800
Convert the binary value of 0101 0100 to decimal
84
What is the value and parameter of the expression? 7 + 5 % 3 Value = ? , Type = ?
9 , Int
Convert 1011111 to decimal
95
What are the values of the inputs if output = 0 ? Not (A*B)
A=1, B=1
What output is produced by the segment of code show? public class WhoMe { public static void main(String args[]){ intx= 25; if(x==25) { System.out.print("BOBBA"); else { System.out.print("FAB"); } } }
BOBBA
What is the output produced by the segment of code: public class WhatAmI { public static void main(String[] args){ System.out.print("BOBO"); p3(); System.out.print("MELON"): p2(); } static pubilc void p1() { system.out.print("IS"); } static public void p2() { system.out.print("HEAD"); } static public void p3 () { p1(); System.out.print("A"); } }
BOBOISAMELONHEAD
What output is produced by the segment of code shown below: public class Who_Am_I{ public static void main(String args[]){ int x = 25; int(x/2 ==12){ System.out.print("BUFFY"); System.out.print("LOVES"); }else{ System.out.print("ZACK"): System.out.print("ISA"); } System.out.print("DIPPY"); } }
BUFFYLOVESDIPPY
What output is produced by the segment of code shown below: public class MY_Jeans{ public static void main(String args[]){ int x = 12; if(x<15) System.out.print("Blue"); }else System.out.print("Green"); System.out.print("Jeans"); } }
Blue
As it related to using the assignment operators show another equivalent way to write this expression: C%=A
C=C%A
This is an example of a _______ algorithim. 1. Reserve the variables double bill, must_Pay 2. Get the necessary information from the user get bill 3. Check the value of the bill and do the necessary calculations if bill > 100 must_pay=bill-bill*0.05 else must_pay=bill show must_pay
Conditional
How do we describe the behavior of gates and circuits? Please select the correct choice, then click "Submit": A. Boolean expressions B. Logic diagrams C. Truth tables D. All of the above
D (all of the above)
Study the code, and determine which call to sum() method is appropriate? Hint the (...) serves a wild card for all method arguments class Output { public stiatic int sum(int...x) { return; } static void main(String args[]) { sum(10); sum(10,20) sum(10,20,30); sum(10,20,30,40); } } A. only sum(10) B. only sum(10,20) C. only sum(10) & sum(10,20) D. all of the mentioned
D (all of the mentioned)
What does the operator, --, decrement do? Ex:--x;
Decrease the value of a variable by 1
What output is produced by the segment of code shown below: public class ilikeFries { public static void main(String args[]){ double Max = 12.7; if(Max>=12) { System.out.print("FRENCH"); } } }
FRENCH
System.out.println("Hawaii:" +5+" "+0)
Hawaii:5 0
What will be the following output of the code? String name = "John"; System.out.println("Hello " + name);
Hello John
Show the output produced by the following statement: System.out.println("If\"pigs\"/nhad\\wings");
If"pigs"/nhad\wings
What does the operator ++, increment, do? Ex: ++x;
Increases the value of a variable by 1
What will the output be for the following code? String name = "John"; System.out.println(name);
John
What will be the following output of the code? String firstName = "John "; String lastName = "Doe"; String fullName = firstName + lastName; System.out.println(fullName);
John Doe
Which logic gate does this truth table belong to? A B X 0 0 1 0 1 1 1 0 1 1 1 0
NAND Gate
What is the output produced by the segment of code: public class WhatIsThis { public static void main(String[] args){ int x = 12; if(x!=12){ System.out.print("YES"); } else System.out.print("NO"); } }
NO
Please evaluate the code then choice the correct output public class Program { public static void main(String[] args) { System.out.println("Print line"); System.out.print("A"); System.out.print("B"); System.out.println(); System.out.print("C"); } }
Print line \n AB \n C
This is an example of a_Algorithim Sum_three_numbers Prompt for three integers Read Value_1+Value_2,Value_3 total=Value_1+Value_2+Value_3 Dispaly total END
Pseudocode
What doe the operator %, modulus, do? Ex: x%y;
Returns the division remainder
What variable stores text, such as "Hello" and values are surrounded by double quotes?
String
Create a variable named carName and assign the value Volvo to it.
String carName = "Volvo";
Which of the possible declarations below is not correct String name ="Paul"; String char="abc", double processorSpeedInGHz= 3.2; double ramSizeInGB - 4; double price = 1650.45; char servicePlan = 'B'; boolean onSiteService = true;
String char = "abc";
Declare and assign a reasonable value to the following: your last initial: ex: p
String char = 'p';
What output is produced by the segment public static void main(String[] args ){ System.out.print("W"); p( ); System.out.print( "Z");} static private void p( ){ System.out.print("X"); System.out.print( "Y"); }
WXYZ
What does the following code fragment write to the monitor? public class Doubt { public static void main(String s[]{ int sum = 21; if(sum!=20) { System.out.print("You win"); } else { System.out.print("You lose"); } System.out.println("the prize."); } }
You win the prize.
Please show the Output public class HelloWorld { public static void main(String[] args) { //escape sequence System.out.println("\\ // -=- \\ //"); } }
\//-=-\//
The input hexadecimal representation of 1110 is ? a) 21 b) 12 c) 22 d) 31
a
Add parentheses to the following expressions to indicate how Java will interpret them. a + -b * c - d
a + (-b) * c - d
Natural language is a set of English language constructs designed to resemble the statements in a programming language but that do no actually run on a computer. a) computers software b) pseudo-code c) Binary d) algorithms
b
Which of the following are legal variable names in Java bestFriend 7daysAWeek hello! TOTAL&CLST privateFIFTYSEVEN57 do
bestFriend, privateFIFTYSEVEN57, do
What variable stores values with two states: true or false
boolean
Declare and assign a reasonable value to the following: whether or not you had lunch today:
boolean ateLunch = true;
This method is use to control algorithm executes its instructions in a straight line from top to bottom and then stops. a) conditional b) algorithms c) seqeuntial d) iterative
c
Which of the following is not a binary number? a) 1111 b) 101 c) 11E d) 000
c
Class name should begin with a?
capital letter
What variable stores single characters, such as 'a' or 'B' and values are surrounded by single quotes?
char
Which variable declaration and initialization is incorrect? int myNum = 5; float myFloatNum = 5.99f; char myLetter = "D"; boolean myBool = true; String myText = 'Hello';
char ; String
The best definition of Computer Science is that it is the study of which of the following? a) computers b) software c) systems d) algortithims
d
Declare and assign a reasonable value to the following: the cost of gas per gallon: ex: $2.06
double gasPrice = 2.06;
What will be the output of the following program? public class ShortTest{ public static void main(String[] args){ boolean x = true; boolean y = false; if (x &&y) { System.out.println(true);} else{ System.out.println(false):} } }
false
true or false? Boolean expressions are more powerful than logic diagrams in expressing the processing of gates and circuits.
false
true or false? The NOR gate produces the opposite results of the XOR gate.
false
What variable stores floating point numbers, with decimals, such as 19.99 or -19.99?
float
What does the = operator do in the following line of code? x= 5;
initializes x as 5
What variable stores numbers(whole numbers), without decimals, such as 123 or -123?
int
Declare and assign a reasonable value to the following: your Grad Year: ex. 2022
int = 2022;
Declare and assign a reasonable value to the following: your waist size: ex: 32
int = 32;
A ___?____ is a program that executes compiled Java code on a specific platform.
java virtual machine
Which method can be defined only once in a program?
main method
What is wrong with the code? public class MyClass { public static void main(String[] args) { System.out.println("Hello World"); }
missing a }
A method declaration contains an access modifier, the name of the method, the the body of the method, and on other item. What is it?
result type
true or false? Logic diagrams and truth tables are equally powerful in expressing the processing of gates and circuits.
true
true or false? The output value of an AND gate when both inputs are 1 is equal to 1.
true
What are the three notational methods for describing the behavior of gates and circuits?
truth tables, logic diagrams, Boolean expressions