FIT1050

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

What is the output of the following piece of code? int x,y,z; x=3; y=5; z=7; z=x=y; System.out.println(x+" "+ y +" "+ z); Select one: a. 5 3 7 b. 7 7 7 c. 3 3 3 d. 5 7 5 e. 3 5 7 f. 15 15 15 g. 5 5 5

G

If your code contains incorrect syntax what is the consequence? Note: the Compiler is the software application that translates your Java code into code a computer can execute. Select one: a. Your code cannot be compiled and therefore cannot be executed b. No consequence. the compiler is smart and can usually figure out your mistake and correct it. c. Your code will run slow d. Your code will run but with unintended semantics e. If you think none of the above are a consequence of your code containing incorrect syntax, select this option

A

Which of the following starts a single line Java comment? Select one: a. // b. //* c. */ d. /// e. If you think none of the above starts a single-line Java comment, select this option

A

Will the following statement sequence compile? If not which line causes the compile error? The line numbers are just for reference. double i; int j = 2; i = j; j = i; Select one: a. No, line 2 b. No, line 3 c. No, line 4 d. Yes e. No, line 1

C

Consider the following code fragment: 1 2 Person tania = new Person(); tania.setAge(21); Which of the following is NOT true about this code fragment? Select one: a. Person is a class name b. Person is a data type c. setAge is a method of the Person class d. setAge is a Mutator method e. tania is a variable f. Using the 'new' keyword to create a new instance is optional g. 21 is a parameter h. tania identifies (references) a particular Person instance i. If you think all of the above are true, select this option

F

Which of the following is NOT a Java operator? Remember, for this question and other questions in this quiz: "When in doubt, try it out (in IntelliJ)". Select one or more: a. || b. != c. <- d. -= e. -- f. === g. ! h. <=

F, C

Which of the following is NOT true about driver classes? Example: 1 2 3 4 5 6 7 8 9 10 11 12 13 public class HelloWorldDriver { public static void main(String[] args) { HelloWorld sayhello = new HelloWorld(); sayhello.hello(); } } public class HelloWorld { public void hello() { System.out.println("Hello, world!"); } } Select one: a. The class name should end with the word Driver b. Objects of driver classes should not be instantiated and therefore driver classes should not contain instance variables c. They should usually contain at least one instantiation statement d. They should usually contain multiple method invocations e. They should be used for testing other thing/concept classes or for starting an application f. They should contain a main method g. If you think all of the above are true select this option

A

Which of the following is NOT true about the Math class? Select one or more: a. It does not provide operations such as roots and powers as these basic mathematical operations (along with +, - *, /) are provided by the Java language b. It contains public mathematical constants c. It never needs importing d. It is not a recipe for a thing/concept instance e. A Math object can be instantiated f. Its methods perform mathematical functions

A, E

Can a Java constant that has been declared and initialised be used to initialise a Java variable? Can a Java variable that has been declared but not yet initialised be used to initialise a Java constant? Select one: a. No, No b. Yes, No c. No, Yes d. Yes, Yes

B

If a statement block is nested inside another statement block which of the following is true? Select one: a. The variables in the inner block are in scope in the outer block but the reverse is not true b. The variables of the outer block are in scope in the inner block but the reverse is not true c. The variables in the outer block are in scope in the inner block and the reverse is also true d. If you think nesting blocks like this produces a syntax error in Java, select this option

B

What does the following expression evaluate to? (double) (24 / ((double) 5)) Select one: a. 5 b. 4.8 c. 5.0 d. 3.5 e. 4.0 f. 4

B

Which of the following data types can only store data approximately? Select one: a. boolean b. float c. int d. String e. long

B

Which of the following is good advice if you want to do well in FIT1051? Select one: a. Don't worry about getting behind. You can always catch up. b. It's a good idea to code in short cycles of writing a small amount of code then testing it immediately. Then if something goes wrong you have a good idea of what code is responsible. c. Don't ignore "plumbing code". Try to understand every piece of code you are exposed to. Getting overwhelmed is just part of coding. d. All code is the same. Mess with it and it breaks. You cannot learn to code by experimenting and playing around with code.

B

Will the following piece of code compile? If not which line causes the compile error? The line numbers are just for reference. int no=10; boolean flag=true; double rate=1.5; String unit="1051"; System.out.println(no+unit+rate); System.out.println(no+flag+unit+rate); Select one: a. no, 5 b. yes c. no, 6 d. no, 3 e. no, 4 f. no, 2 g. no, 1

B

Given the following syntax template: dataType variableName [, variableName [= dataValue] ]...; Would it be valid to declare a variable with an initial value and a variable without an initial value in the same declaration statement? Select one: a. No b. Yes without restrictions c. Yes with restrictions

C

If the value of x is 20, what does this expression evaluate in Java? 0<= x < 30 Select one: a. true b. false c. It will not compile

C

What does the following expression evaluate to? boolean flag="abcd".compareTo("abCd ") > 0; Select one: a. false b. The expression has a syntax error c. true

C

What left operand value and right operand value respectively does the multiplication operator operate on in the following expression? You can assume i has the initial value of 5. i-- * i--Hint: try it out in IntelliJ and work backwards to deduce what must have happened. Select one: a. 4, 4 b. 4, 3 c. 5, 4 d. 5, 5 e. 3, 3

C

A class's Instance Variables are declared: Select one: a. In the class's header b. Outside of all of the class's code c. In the code of the class's methods d. In the headers of the methods of the class e. In a class's code but outside of all its methods

E

An instance variable is a storage location in memory that contains: Select one: a. The name of a data item of a class b. Part of the state of an instance of a class c. The current value of a class's data item d. The current value of a data item of an object of a class e. More than one of the above is correct

E

What is the most certain syntactic hint of a method's name? For example, square @line 4 is a method name. Why? 1 2 3 4 5 6 7 8 9 10 11 class SquareMain { public static void main(String[] args) { int result; result = square(); System.out.println("Squared value of 10 is: " + result); } public static int square() { // return statement return 10 * 10; } } Select one: a. It begins with a lower case letter b. It's followed by an opening brace (curly bracket) c. It's in camel case (begins with a lower case letter then new words begin with an upper case letter e.g. forExample) d. It's made up of lower case letters only e. It's followed by an opening parenthesis (round bracket)

E

Which of the following is NOT true for both Java variables AND Java constants? Hint: If you are unsure try it in IntelliJ. This applies to all questions in this pre-reading quiz. Select one: a. Neither can be used without first being declared b. Both can be initialised at declaration c. Both must have a data type d. Both can be initialised after declaration e. Both can have a name that begins with a number f. If you think all of the above are true for both Java variables and Java constants, select this option

E

What symbol is used to start and finish both a class's code and a method's code? Select one: a. Curly braces: {} b. Square brackets: [ ] c. Parenthesis: () d. Semi colon: ;

A

Will the following statement sequence compile? If not which line causes the compile error? The line numbers are just for reference. int i; int j = i; j = 3; Select one: a. no, line 3 b. no, line 1 c. no, line 2 d. yes

D

What is wrong with the following statement? double no1=10,n2o=3.6,no3; Select one: a. Nothing is wrong. The statement is syntactically correct b. no1 must be initialized with a double value c. We cannot separate the variables by a comma ',' d. n2o variable name is incorrect e. no3 must initialized for the statement to get compiled.

A

What makes up a method's inputs and output respectively? Select one: a. Parameters, Return Value b. Return Values, Parameter c. Parameters, Parameter d. Return Values, Return Value e. If you think none of the above make up a method's inputs and output respectively, select this option

A

If the following expression was evaluated for each integer between 10 and 150 inclusive how many times would it return true? i % 17 == 0 Select one: a. 8 b. 10 c. 0 d. 7 e. 9 f. 1

A

What is the output of the following piece of code? int x = 4, y = 3; boolean b = ++x < y++ || ++x < y++; System.out.println(x+","+y+","+b); Select one: a. 6,5,false b. 5,6,false c. 4,3,false d. 4,3,true e. 5,4,false f. 5,4,true

A

Which of the following is NOT true? Select one: a. Accessor methods must include a return statement with a return expression Example: 1 2 3 4 5 6 7 private String myField; //"private" means access to this is restricted public String getMyField() { //include validation, logic, logging or whatever you like here return myField; } b. Mutator methods must have an input parameter Example: 1 2 3 4 5 6 7 8 private String myField; //"private" means access to this is restricted public void setMyField(String value) { //include more logic myField = value; } c. Mutator method code is responsible for maintaining the integrity of an object's data d. Accessor and Mutator methods are always public because they are intended to be used by code outside their class e. Mutator methods must include a return statement with a return expression f. If you think all of the above are true, select this option

E


Ensembles d'études connexes

Chapter 19: Diseases Affecting Vision and Hearing

View Set

Anthropologie de la communication.

View Set

Chapter 9- Muscles and Muscle Tissues

View Set

PSY-100 15b. The Biomedical Therapies and Preventing Psychological...

View Set

MGMT 3385- Diversity in Organizations Final Exam Study Guide

View Set

Psy Ch. 1 Quiz 1: What is Psychology? Science versus Intuition

View Set

Chapter 20: Recombinant DNA Technology and Gene Cloning

View Set