Java Quiz
Real world objects share what two characteristics?
Inheritance and Polymorphism
Times and Dates
State and Behavior
Classes and interfaces
In object-oriented programming how is state represented?
Global variables
Member variables
Methods
Functions
In object-oriented programming how is behavior represented?
Instance variables
Member variables
Methods
Functions
What is the purpose of a class
Serve as the blueprint of how objects will be created
To create a data structure for variables
To create a data structure for functions
To create an interface for implementation
Based on best practices and how the Java API Library is implemented a class should start with a capital letter(i.e. Dog versus dog)
True
False
When defining a class, member variables are included within the class's open/close curly braces (i.e. {}) and methods are defined outside of the open/close curly braces.
True
False
Information hiding is accomplished via encapsulation
True
False
Which of the following is the correct code for instantiating the class Dog?
Dog puppy = new Dog();
Dog puppy = Dog();
Dog puppy;
Dog puppy = Dog;
Which part of the following statement is the instance of the created object? Dog puppy = new Dog();
Puppy
Dog();
New
Dog
In the following statement , Dog puppy = new Dog(); what is "Dog()" called?
Malloc
Creator
Maker
Constructor
The new class is called
Superclass
Subclass
How many superclasses can a subclass have?
1
Unlimited
3
2
How many subclasses can a superclass have?
2
3
Unlimited
1
Given the definition public class KeyTerminology{} what is public called?
Membership level
Data type of class
Access level modifier
Not relevant
What type of implementation behavior is the following class definition doing? Public class SubclassDog extends Dog{}
Inheritance
Extending
Implementation
Interface
When creating a subclass from a superclass what key word must precede the existing superclass?
Implements
Uses
Inherits
Extends
What behavior is the followind code implementing? Public class DogTwo implements Dog{}
Interfacing and implementation
Extending a subclass
Ending a superclass
Implementing an interface
What is the minimum number of interfaces a class can implement?
0
Unlimited
2
1
What is the maximum number of interfaces a class can implement
2
10
1
Unlimited
What is the purpose of paackages in Java as an object oriented programming language?
Namespace for organizing classes and interfaces in a illogical manner
To include into the Java API
Make it difficult to manage software in large projects
Namespace for organizing classes and interfaces in a logical manner
Which of the following is NOT the number of operands an operator can perform specific operations on?
Unlimited
2
1
3
Operators do not have precedence rules
True
False
Which of the following are ways to output to the console during runtime?
System.out.print()
System.out.println()
Fprintf()
Printf()
What is the difference between System.println() and System.out.print()?
Nothing, they do the same thing
.print() includes a line break, .print() does not
.print() includes a line break, .print() does not
The + (plus sign) has two purposes in the Java programming languages, select the two that are correct.
Concatenation
Modulus
Addition
Division
Subtraction
Multiplication
Unary operators use how many operands
3
1
Unlimited
2
What is true about the ternary operator? Select all that apply
Uses one operand
Must have its result assigned to a variable on the left of an = (equals sign)
Uses three operands
Uses two operands
Shorthand if else statement
Instanceof is
A method
An operator
None of the options are correct
A function
In object -oriented programming where are inner classes defined?
Outside another class but in the same file
Outside another class in a different file
Inside of another class
This isn't allowable
Which of the following NOT the number of operands an operator can perform specific operations on?
Unlimited
2
1
3
Operators do NOT have precedence rules
True
False
How are statements in a source code file normally executed?
Conditionally
Sequentially
Randomly
In reverse order
What is the purpose of control flow statements?
To break up the flow of execution
To ensure execution from bottom to top
To ensure sequential execution
Wo ensure execution from top to bottom
What is the most basic of all control flow statements?
Do/while
Switch
If
If/else
An if/else provides what?
Two conditions to be evaluated for a true result
A secondary path of execution when an "if" clause evaluates to false
Two conditions to be evaluated for a fale result
Nothing
Given the following class and interface definitions (location does not matter): static class Parent {} static class Child extends Parent implements MyInterface {} interface MyInterface {} public static void main(String[] args) { Parent obj1 = new Parent(); Parent obj2 = new Child(); boolean result = (obj1 instanceof Parent); } What is the value of result?
True
False
Given the following class and interface definitions (location does not matter): static class Parent {} static class Child extends Parent implements MyInterface {} interface MyInterface {} public static void main(String[] args) { Parent obj1 = new Parent(); Parent obj2 = new Child(); boolean result = (obj2 instanceof Parent); } What is the value of result?
True
False
Given the following class and interface definitions (location does not matter): static class Parent {} static class Child extends Parent implements MyInterface {} interface MyInterface {} public static void main(String[] args) { Parent obj1 = new Parent(); Parent obj2 = new Child(); boolean result = (obj1 instanceof Child); } What is the value of result?
True
False
Given the following class and interface definitions (location does not matter): static class Parent {} static class Child extends Parent implements MyInterface {} interface MyInterface {} public static void main(String[] args) { Parent obj1 = new Parent(); Parent obj2 = new Child(); boolean result = (obj2 instanceof MyInterface); } What is the value of result?
True
False
If the condition being evaluated in the source code below evaluates false, what happens? If(age >= 18) System.out.println("You are old enough to vote! Please register to vote, elections are this year!");
Control jumps to the end of the if statement
Nothing
The System.out.println() will be executed providing output to the console
Variable age will b e set to 0
An if/else provides what?
Two conditions to be evaluated for a true result
Secondary path of execcution when an "if" clause evaluates to false
Two conditions to be evaluated for a false result
Nothing
Given the source code below, what would be the output to the console? Int age= 18; if(age >= 21) system.out.println("You are old enough to purchase alcohol"); else System.out.println("You are not old enough to purchase alcohol");
You are old enough to purchse alcohol
You are not old enough to purchase alcohol
Nothing
U are old enough to purchase alcohol and You are not old enough to purchase alcohol
If you need evaluated more than one condition which decision-making statement is the best?
If
While
Else if/else
If/else
In an if/else if/else, once a condition is satisfied, are the remaining conditions evaluated?
Yes
No
It depends
Mayeb
In an if/else is the final else leg REQUIRED?
Yes
No
For a switch decision-making statemnet is there a limitition on the data type of the evaluated variable (o.e. ANY data type including instances of classes)?
No
Yes
What is the body of the switch decision making statement called?
Options block
Case labels
E block
Switch block
For each case label in a switch decision-making statement the break is not required but are necessary to prevent statements in switch blocks from falling through
True
False
In the final case label of a switch decision-making statement, the break is still required and necessary
False
True
{"name":"Java Quiz", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"real world objects share what two characteristics?, In object-oriented programming how is state represented?, In object-oriented programming how is behavior represented?","img":"https://www.quiz-maker.com/3012/images/ogquiz.png"}
More Quizzes
Hair Evaluation!
1260
Mar
1269
Athena's LC
18930
Native Americans
520
Preliminary Examination-Introduction to Psychology
251222
Raquan
320
What Book Should I Read?
8417
Estudiantes C. Villanueva. Proyecto Sport Fashion Lab. Formulario inicial.
940
KFL Quiz
100
How Install Gta 5 Apk Easy
100
Appointment Setting Quiz
100
History of Cafe Catholica Quiz
1167