UAB CS 203 Final Exam 2023
public static void main(String args [ ]) { int i = 0 do { System.out.println( i ); i++; } while ( i > 5 ); } Whats the output
0
What is used to run the bytecode on each platform
Java Virtual Machine
Is white space important in Java
NO
A method should be an accessor or mutator but not both
True
Accessor method does not change data
True
An immutable has no mutator methods
True
Every Variable in java needs a data type
True
Java supports multilevel inheritance
True
what can be used instead of switch - else statement
if - else
which statement is not an access modifier in java
inherited
Constructors are used to
initialize a newly created object
how to create a variable with an int of 5
int x=5;
whats the proper notation for two conditions both being true
&&
how many classes should have a main method
1
In JAVA, you can compare an int with a boolean variable
False
In Java, you declare the type of a variable in your code, and you can change the type of that variable later
False
Instance variables belong to the class not any specific object
False
It is good practice for instance variables to be public
False
Java doesn't support multidimensional arrays
False
Java is short for JavaScript
False
Mutator methods dont change the data of the object
False
String is mutable
False
The value of a string can be surrounded by single quotes
False
public class Faculty extends UABEmployee,Researcher{ } is the correct to make a subclass
False
we can change the argument list of an overriding method
False
we can inherit from multiple abstract classes
False
we can only construct one object per class
False
we can store the integer values inside an arraylist using the following code Arraylist <int>
False
whats the output to this code public static void main(String[ ] args) { String str1 = new String("CS203"); String str2 = new String("CS203"); System.out.println(str1 == str2); }
False
This operation yields true if either or both of of the operands are true
II
which is a good class name
Number
Can an Object have more than one type of Data?
Yes
Overriding
where two methods have the same name AND the same parameter types, but the implementation has been changed in the subclass
Overloading
where two methods have the same name BUT different parameter types. which the implementation changes based on the type of the parameter
What is not true about inheritance in Java
you can inherit from multiple classes at the same time
which is true
you must initialize local variables
What is the base class of all classes in Java
Object
which statement is not true
References are mutable
we have superclass "Asset" and subclasses "Stock", "Bond", "Savings". What is not possible
Savings obj4 = new Asset( );
what class allows the user to input data from their keyboard
Scanner
Which data type is used to create a variable that should store text
String
Method overloading is a feature of OOPs which makes it possible to give the same name to more than one method within a class if the arguments passed differ
True
There is no need to create the object to call the static methods
True
do - while loops are guaranteed to run at least once
True
in the OOP concept, data and code are bound together by encapsulation
True
variables should usually be private
True
when we extend a superclass we have a choice whether or not to override the methods of the superclass
True
which is not true about JUnit Testing
Unit testing mean testing one java file at a time
keyword used for checking a reference variable for a type of object reference
instanceof
a template needs to be defined for a group ofsubclasses (for example, Animal should be an abstract superclass) What should you use?
Abstract class
which OOP concept forces programmers to override a method
Abstract classes
What does API stand for
Application Programming Interface
what is an unordered sequence that stores references to objects
Arraylist
If class B inherits from class A which of the following cannot be said
B has access to private methods in class A
Is Java an interpreted language or a compiled language?
Compiled
Abstract class is a OOP concept where one object can have many forms
False
Abstract classes can be instantiated
False
Where can local variables be accessed?
Inside the method or block that they are defined in
Which is true about abstract classes
It forces programmers to override a method
whats the correct way to create an object called myObj of MyClass
MyClass myObj = MyClass( );
All inner classes types
Nested inner class method local inner class anonymous inner class static nested inner class
A derived Class automatically has all the instance variables and public methods that the base Class has, and it can have additional methods and/or instance variables as well
True
A static variable belongs to the class, not an object of the class
True
Accessor method does not change the internal data of the object on which it is invoked
True
what is true about a public access modifier
Variables, methods and constructors that are declared public can be accessed by any class
to declare an array in java, define the variable type with
[ ]
inner class
a class that is part of another class or method
what identifier sets a variable as True or False
boolean
which statement is used to stop a loop
break
what is the output of a Java program called
bytecode
what keyword is used to create a class om Java
class
Abstraction hides what
complexity
In Java, how do you get a for loop to skip a current iteration under certain conditions
continue
what is the result of the code int num = 6.45
error
which object is not a primitive type
object
When a child class declares a method that has the same type arguments as a method declared by its parent class is called
overriding
You have two methods in the parent class public void method1( ) { ... } private void method2( ) { ... } which is not possible with inheritance
private void method1( ) { ... }
what is NOT true about constructors
return type is always int
Whats a keyword that accesses the methods or member variables of the parent class
super
what refers to the object a method is being called on
this