Java Test 1

Operators are special symbols that perform specific operations on up to how many operands?
One
Two
Three
Four
None
Regarding operator precedence which of the following would be evaluated first?
=
*
+
Instanceof
++
What is the purpose of the assignment operator?
Assigns the value on the left to the operand on the right
Assigns the value on the right to the operand on the left
To check for equality
To check for identical
None of the above
The + operator performs two operations, which of the following is true?
Assignment
Concatenation
Addition
A and C
B and C
How many operands do unary operators require?
One
Two
Three
Four
None
Regarding conditional operators (ie &&, ||) what does "short circuiting" behavior mean?
Both operands/expressions are evaluated
Only the second operand/expression is evaluated
Only the first operand/expression is evaluated
The second operand/expression is evaluated if needed
None of the operands/expressions are evaluated
What does the instanceof operator do?
Tests if the compared operands are equal
Tests if the compared operands are identical
Tests if the expression is true
Tests if the expression is false
Tests if the object is an instance of a class, subclass, or implements an interface
A programmer should always chose any input or output stream when done accessing the resource
True
False
It depends
A(n) _________ comprises variables, operators, and method invocations.
Expression
Statement
Abstract class
Class
Interface
A(n) ________ forms a complete unit of execution to include a terminating semicolon
Expression
Expression statement
Abstract class
Class
Interface
A(n) ______ declares a variable
Expression
Expression statement
Declaration statement
Class
Interface
What is used in programming to block a group of zero or more executable statements?
[]
()
<>
{}
/**/
What is the purpose of control flow statements?
To allow programs to run sequentially
To allow programs to run line by line from top to bottom
To allow programs to run with a break up of execution flow
All of the above
None of the above
If a programmer writes a control flow statement using if - else if - else if ... Are they required to include an else leg?
Yes
No
If a programmer writes a control flow statement using switch... Are they required to include a default case label?
Yes
No
Regarding classes, instance variables are ________
Static
Non-static
Both A and B
None of the above
Regarding classes, class variables are _______
Static
Non-static
Both A and B
None of the above
Local variables store a _____ state
Permanent
Static
Instance
Temporary
None of the above
Parameters are different than arguments because parameters are used when ________
A method or constructor is defined
A method or constructor is called
A class is defined
An interface is defined
An abstract class is defined
Parameters are different than arguments because arguments are used when _________
A method or constructor is defined
A method or constructor is called
A class is defined
An interface is defined
An abstract class is defined
Variable naming has rules associated with it. Which of the following is true?
They can start with a number
They can start with any special character
They can include white space
All of the above
None of the above
In object-oriented terms what is used as a blueprint to model a real-world object?
Method
State
Behavior
Constant
Class
Object-oriented programming allows for inheritance so commonly used state and behavior can be reused. The class that is inherited from is the _______ and the new class is the _________
Superclass, subclass
Subclass, superclass
Interface, subclass
Class, package
Extends, implements
How many superclasses can a subclass extend when using inheritance in object-oriented programming using the Java programming language?
Zero
One
Two
Three
Unlimited
When using Inheritance what does the new class inherit when it is derived from another class?
State, behavior
Object, class
Inheritance, interface
Function, method
Project, package
When implementing an interface in object-oriented programming all ________ must be included in the source code for the class to compile
State
State and behavior
Superclasses
Constructors
Methods
An expression statement forms a complete unit of execution with a terminating semicolon. The following code is a correct example of an expression statement: Game game = new Game();
True
False
Does the following code include all required components for a class declaration? Public class NewClass { }
Yes
No, it's missing the fields and methods
No, the access modifer is not required
No, it's missing the return type
No, it's missing the parentheses and parameter list
What are the components of a method declaration that comprise the method signature?
Method return type and method name
Method return type and method parameter list
Method return type, method name, and method parameter list
Method name and method parameter list
All of the above
Does the following code include all required components for a method declaration? Void thisMethod() { }
Yes
No, it's missing the access modifer
No, it's missing the return type
No, it's missing the parameter list
No, it's missing the argument list
Which of the following are types of class member variables?
Fields
Local variables
Parameters
All of the above
None of the above
The object-oriented concept of software reuse allows a class to be created one and used ________
Never
Once unless it is extended using inheritance
As many times as desired to include extending it using inheritance
Ten times or less
Once unless it is implemented using interface
If a class explicitly declares a constructor that takes 0... N parameters when instantiated what happens to the default constructor of the class?
It still exists and can be used to create instances of the class
It is automatically created by the Java complier
It is longer exists
All of the above
None of the above
A class that is declared final can be extended or subclasses
True
False
When does a method return to the code that invoked it?
Completes all the statements in the method
Reaches a return statement
Throws an exception
A or B
A,B or C
Classes that cannot have objects created from them are called what?
Abstract
Concrete
Interfaces
Inheritance
Polymorphism
An abstract method is a method that is:
Declared without implmentation
Has no curly braces
Ends with a semicolon
A, B, and C
None of the above
A subclass of an abstract class must provide ______ for all abstract methods of the superclass to be considered a concrete class
Interfaces
Implementation
Guidance
Comments
Shadowing
What is the automatic access modifier of methods and fields of interfaces?
Package
Public
Package-private
Private
Protected
What does the keyword final indicated regarding methods or field members of a class?
They cannot be modified
They are public
They are private
They are modifiable
None of the above
If there are an unknown number of parameters being passed to a method a software developer can use a construct called _______
Varargs
An array
An ArrayList
A 2-D array
None of the above
The ternary operator takes three operands and uses the (?:) notation. What control structure does the ternary operator mimic?
If/else
While loop
Switch
For loop
Do/while loop
Regarding object-orientated programming, declaration means that a variable name is associated with an object type and creates an object of that type
True
False
When method parameters have the same name as a class fields this is called _______
Repetition
Duplication
Same name
Shadowing
Confusion
When having to programmatically differentiate a parameter having the same name as a field of a class what keyword can resolve this issue with the compiler when setting the field value equal to the argument value passed into the method?
Keyword
This
Parameter
Argument
In
Regarding object-oriented programming, when an object is instantiated the keyword new is used, memory is allocated, and a reference to that memory is returned.
True
False
An interface can and should be instantiated
True
False
How are primitive and reference data arguments pass into a method?
By reference
By physical location
By value
By object location
None of the above
A method in object oriented programming can return primitive data types, _________, or ____________
Project, package
Function, method
Constructor, exception
Class, interface
Code, return
The keyword this is used to reference _________
The inheritance
The interface
The subclass
The current object
The class's destructor
Interfaces and abstract classes can have objects instantiated from them
True
False
Operators with higher precedence are evaluated ______ operators with relatively _____ precedence
After, lower
Before, higher
Before, lower
After, higher
None of the above
When defining classes in the Java programming language a software developer can extend _____ superclasses and implement ____ interfaces
Unlimited, one
Two, unlimited
One, unlimited
Unlimited, two
Unlimited, unlimited
A class that uses an explicit constructor invocation uses the keyword this to _____
Call another constructor in the same class
Call the super constructor
User recursion and call itself
Call another constructor in a different class
Call the constructor of the implemented inface
What a method has a return type other than void what data type can be returned from that method?
No return value is required
The returned data type can be any data type valid in the Java programming language
The returned data type must match the declared return data type
The returned data type should be String
None of the above
Access level modifiers do not define how other classes can reference a field or invoke a method
True
False
What allows for methods to have the same name but different method signatures in object-oriented programming?
Class overriding
Method overriding
Class overloading
Method overloading
Shadowing
What differentiates methods with the same name in a class?
Return type
Access modifier
Argument list
Parameter list
None of the above, this is not permitted
A class can have multiple constructors
True
False
Encapsulation of class fields hides implementation details. How is encapsulation used to access fields of classes?
Private methods are written to interact with the private fields
Public methods are written to interact with public fields
Private methods are written to interact with the public fields
Public methods are written to interact with the private fields
None of the above, encapsulation is not a real topic in object oriented programming
In object oriented programming classes, keywords, methods, variables, interfaces, and abstract classes are not case sensitive.
True
False
What is a key difference between an if / else if / else and a switch control flow statement?
Switches stop evaluating when it finds a true condition
If / else if / else stop evaluating when it finds a true condition
Both stop evaluating when it finds a true condition
If / else if / else continues evaluating after it finds a true condition
None of the above, there is no difference
Regarding file pathing there are two options, absolute and relative. Which of the following statements is true?
Absolute never includes the root element and the complete directory list required to access the file
Relative needs to be combined with another path to access the file
Absolute needs to be combined with another path to access the file
Relative always includes the root element and the complete directory list required to access the file
There is no difference
Entomophagy is the practice of eating insects and bugs. Which is the world's tastiest insect?
Nigeria's crickets
China's earthworm soup
Macao's fried beetles
Brazil's stingless bees and wasps
I would eat them all
{"name":"Java Test 1", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"Operators are special symbols that perform specific operations on up to how many operands?, Regarding operator precedence which of the following would be evaluated first?, What is the purpose of the assignment operator?","img":"https://www.quiz-maker.com/3012/images/ogquiz.png"}
Powered by: Quiz Maker