Literally Exam 1 + Exam 2

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

The value of a string variable can be surrounded by single quotes

False

True/False: Abstract Class is a OOP concept where one object can have many forms.

False

True/False: Abstract Classes can be instantiated

False

True/False: Code can be reused through inheritance thereby increasing redundancy

False

Constructors are used to ____________

Initialize a newly created object

____________ defines only abstract behavior, thus it supports the OOP abstraction concept

Interface

Which statement is not True about local variables?

Local variables can be used in any other method

Which statement is not True about local variables? Local variables can be used in any other method Local variables belongs to methods Local variables are declared in the body of a method Local variables must be initialized

Local variables can be used in any other method

Which of the following is not an exception type? Error Memory Checked Runtime

Memory

What is the correct way to create an object called myObj of MyClass?

MyClass myObj = new MyClass();

If you want your condition to depend upon two conditions BOTH being True, what is the proper notation to put between the two Boolean statements?

&&

Abstraction hides __________?

complexity

Within Java, you need to code your program so that under certain conditions it will skip the current iteration of a for loop. What can be used to accomplish this?

continue

Which of the following statement is True about JAVA exceptions?

finally block always executes

What keyword is used to allow one class to use an interface? instanceof implements inherits extends

implements

Which statement is not an access modifier in JAVA? protected inherited private public

inherited

True/False: Accessor method does not change the internal data of the object on which it is invoked.

True

True/False: All methods of and interface are implicitly public and abstract

True

True/False: An immutable class has no mutator methods

True

True/False: An interface type does not have instance variables

True

True/False: Every variable in JAVA need a data type

True

True/False: In the OOP concept, data and code are bound together by encapsulation

True

True/False: JAVA supports multilevel inheritance

True

True/False: 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

True/False: There is no need to create the object to call the static methods.

True

True/False: When we extend a superclass we have a choice whether or not to override the methods of the superclass

True

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

____________ is a keyword that is used for checking if a reference variable is containing a given type of object reference or not? (if this object belongs to this particular class, or not...)

instanceof

How do you create a variable with the numeric value 5?

int x=5;

Why is inheritance advantageous?

it allows Classes to be Reused, without having to copy it into the definitions { } of the derived Classes

_______ refers to the object a method is being called on.

this

There is no need to create the object to call the static methods.

True

True/False: We can inherit from multiple abstract classes

False

Which keyword is used to create a class in Java?

class

What is the result of the following code? int num = 6.45;

Error

Which of the following statement is not True? A class depends on another class if its methods use that class in any way We should place code for producing output/consuming input inside the constructor method Always strive to decouple input and output from classes' work We should reduce the dependency as much as possible

We should place code for producing output/consuming input inside the constructor method

Which of the following statement is True? You must initialize the local variables Local variables belongs to the class Instance variables belongs to method Object references are set to zero

You must initialize the local variables

To declare an array in Java, define the variable type with:

[]

What is the expected output of the following code? public static void main(String args[]) { int i = 0; do { System.out.println(i); i++; }while (i > 5); }

0

What is the output of the following code? public static void main(String args[]) { int x = 10; for (int y=0; y<5; y++, x--) System.out.print(" " + x); }

10 9 8 7 6

Which statement is not True about the Variables? A local variable can be accessible from anywhere A static variable shared by all instances of the class A static variable belongs to the class A global variable doesn't belong to a specific method

A local variable can be accessible from anywhere

Which OOP concept forces the programmers to override a method

Abstract Classes

Which statement is not True about the Classes?

All classes must include a main() method

Which statement is not True about the Classes? The public interface of a class should be cohesive A class should represent a single concept In order to identify a class, we should look for the nouns

All classes must include a main() method

Which of the following statement is not True? In order to reduce the dependency, we should decrease the number of attributes We should minimize the dependency as much as possible Abstraction is a technique for structuring computer programs Abstraction reduces things down to the simplest components possible

Answer: In order to reduce the dependency, we should decrease the number of attributes

____________ is an unordered sequence that stores references to objects

Arraylist

Which of the following is not True about Unit Testing? The test cases are designed before or during the implementation Junit is a testing framework which automates the testing process Unit testing means testing one java file at a time We should run the tests after each implementation change

C) Unit testing means testing one java file at a time

Consider the following code fragment. What is the printed output? public static void main(String args[]) { String str1 = "CS"; String str2 = "CS 203"; String str3 = "203"; String c = "";//empty space String s1 = str1 + str3; String s2 = str1 + "c"; String s3 = str1 + c; String s4 = ""; s4 += str1; String s5 = s4 + str3; System.out.println(s5); }

CS203

Assume you have two methods in the Parent class public void method1(){ ... } private void method2(){...} Which of the following is not Possible for the inherited subclass A) public void method1(){...} B) private void someOtherMethod(){...} C) public void method2(){...} D) private void method1(){...}

D) private void method1(){...}

Java uses _______________ for much of its error handling

Exceptions

Class is the base class (super class) of all classes in java.

False

In JAVA, we can compare int variable with a boolean variable

False

Java is short for "JavaScript".

False

Which of the following is True about Abstract Classes? It doesn't include any methods It forces the programmers to override a method The abstract classes don't have a class name It can be instantiated in the tester file

It forces the programmers to override a method

Which of the following statement is not true about JAVA?

It is an interpreted language

________________ is used to run the bytecode on each platform.

Java Virtual Machine

________________ is used to run the bytecode on each platform.

Java Virtual Machine (JVM)

True/False: Interfaces must have at least one constructor

False

True/False: JAVA doesn't support multidimensional arrays

False

True/False: The following is a correct statement to create a subclass public class Faculty extends UABEmployee,Researcher{}

False

True/False: UML is an Object-Oriented Programming Language

False

True/False: We can change the argument list of an overriding method

False

True/False: We can store the integer values inside an arraylist using the following code; Arraylist <int>

False

We can only construct one object per class

False

String is a mutable class

False

_______ is a keyword which is used to access the methods or member variables of the parent class

super

In Java, you declare the type of a variable in your code, and you can change the type of that variable later on.

False

Mutator methods don't change the data of the object

False

What is the correct way to create an object called myObj of MyClass? class MyClass = new myObj(); MyClass myObj = new MyClass(); new myObj = MyClass(); class myObj = new MyClass();

MyClass myObj = new MyClass();

Two or more methods with the same name in the same class with different arguments is called as ___________

Overloading

REVIEW SLIDE 7-14

REVIEW SLIDE 7-14

Which of the following statements is not True? There can be multiple variables referencing same object A reference is the location in memory that an object resides References are mutable The value of an object variable is a reference

References are mutable

Assume we have one superclass "Asset", and three subclasses; "Stock", "Bond", and "Savings". Which of the following is not possible? Savings obj4 = new Asset(); Asset obj2 = new Stock(); Asset obj1 = new Bond(); Bond obj3 = new Bond();

Savings obj4 = new Asset();

Which data structure is used to store the values of functions calls? (Hints: multiple function calls...... function calls another function and it calls another function.....)

Stack

Which of the following statement is not True about JAVA object?

The object can have only one type of data

Which of the following statement is not True about JAVA object? The object is reusable The object can have only one type of data The object has operations The object has data

The object can have only one type of data

Inheritance

The process by which a new Class is created from another Class

Which of the following statement is not True about JAVA?

The white spaces and the indentation is important

Which of the following statement is not True about JAVA? The output of the JAVA program is called bytecode Functions must declare the types they return The white spaces and the indentation is important

The white spaces and the indentation is important

A static variable belongs to the class, not any object of the class

True

Accessor method does not change the internal data of the object on which it is invoked.

True

An immutable class has no mutator methods

True

Do - while loop is guaranteed to run at least one time

True

Every variable in JAVA need a data type

True

True/False: 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

Whenever we create a method, it should be either an accessor or mutator method, not both.

True

Which of the following is true about the public access modifier? Variables, methods and constructors which are declared public can be accessed by any class lying in same package Variables, methods and constructors which are declared public can be accessed by any class Variables, methods and constructors which are declared public in the superclass can be accessed only by its child class Variables, methods and constructors which are declared public can be accessed by only the accessor methods of that class

Variables, methods and constructors which are declared public can be accessed by any class

Which of the following is true about the public access modifier? Variables, methods and constructors which are declared public can be accessed by any class lying in same package Variables, methods and constructors which are declared public can be accessed by only the accessor methods of that class Variables, methods and constructors which are declared public can be accessed by any class Variables, methods and constructors which are declared public in the superclass can be accessed only by its child class

Variables, methods and constructors which are declared public can be accessed by any class

Which of the following is True about Interfaces? It doesn't include any abstract method We can implement multiple interfaces at the same time It must be defined inside another method It is not a valid reference type in JAVA

We can implement multiple interfaces at the same time

Which of the following statement is not True about JAVA inheritance? We should apply "is-a test" to decide whether using inheritance or not Inheritance increases the reusability of the code We can't inherit the private methods We can inherit from multiple class at the same time

We can inherit from multiple class at the same time

If we need to create a class that needs to inherit the common features of multiple different classes, what should we do? We need to implement multiple interfaces The new class must be declared as an abstract class We must extend multiple classes and declare the new class as a subclass We need to create the class as an abstract class

We need to implement multiple interfaces

Which statement is used to stop a loop?

break

The specialized Classes are said to

inherit the public methods and public and private instance variables of the general Class

When the child class declares a method that has the same type arguments as a method declared by its parent class is called as _____________

overriding

A ____________ of a method is any externally observable data modification (state change)

side effect


Ensembles d'études connexes

Standard costing and variance analysis - Theory

View Set

Bailey Sociology Final: Quiz Questions

View Set

Personal Money Management (BFIN 1003) - Final Exam

View Set

Intercultural Communication Chapter 9 and 10

View Set

Chapter 10: making capital investment decisions

View Set