JAVA Part 1

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

Any Java object that can pass more than one _____-____ test is considered to be polymorphic

Any Java object that can pass more than one IS-A test is considered to be polymorphic

Get methods are also commonly called one of the following: 1. accessor methods or query methods 2. non-static methods 3. static methods 4. mutator methods

1

The compiler differentiates signatures by one of the following: 1. the number of parameters, the types of the parameters and the order of the parameter types in each signature. 2. the number of parameters only. 3. the order of the parameter types in each signature only. 4. the types of the parameters only.

1

What are classes that can be used to instantiate objects called? 1. Concrete classes 2. Final classes 3. Abstract classes 4. Blended classes

1

What is the main function of a Java compiler? 1. It translates the Java source code into bytecodes that represent the tasks to execute. 2. It examines the bytecodes to ensure that they are valid and do not violate Java's security restrictions. 3. It executes the bytecodes 4. It places the program in memory to execute it

1

Which of the following is not a correct statement about Polymorphism in Java. 1. Polymorphism enables you to "program in the general" rather than "program in the specific. 2. Polymorphism enables you to "program in the specific" rather than "program in the general." 3. Polymorphism enables you to write programs that process objects that share the same superclass as if they were all objects of the superclass 4. Relying on each object to know how to "do the right thing" in response to the same method call is the key concept of polymorphism.

1

Which of the following statements is true about a super class' private members? 1. A superclass's private members are hidden from its subclasses 2. When a subclass method overrides an inherited superclass method, the superclass version of the method cannot be accessed from the subclass by preceding the superclass method name with keyword super and a dot (.) separator. 3. They cannot be accessed only through the public or protected methods inherited from the superclass 4. Subclass methods cannot refer to public and protected members inherited from the superclass simply by using the member names.

1

Identifiers

Class, method and variable names are identifiers. By convention all use CamelCase names. Class names begin with an uppercase letter Method and variable names begin with a lowercase letter.

Which of the following statement is false about Java instance variables? 1. The value of the instance variables are not shared among objects of the same class. 2. Instance variables are not automatically initialized 3. The default value for an instance variable of type String is null 4. Every instance variable has a default initial value - a value provided by Java when you do not specify the instance variable's initial value.

2

Which of the following statements is false about abstract super classes? 1. Can use abstract superclass names to invoke static methods declared in those abstract superclasses. 2. You can instantiate objects of abstract superclasses if you implement only one method out of many abstract methods from its abstract superclass. 3. You can use abstract superclasses to declare variables. 4. You cannot instantiate objects of abstract superclasses,

2

Which of the following statements is not a valid rule about constructors in the context of inheritance? 1. In general, constructors are not inherited. 2. In the sub-class level, constructors cannot be overloaded. 3. In the sub-class level, constructors can be overloaded. 4. The first task of a subclass constructor is to call its direct superclass's constructor explicitly or implicitly.

2

Which of the following statements is true in relation to the life of an instance variable? 1. Instance variables exist even before methods are called on an object and lasts only till methods are called on an object. 2. Instance variables exist before methods are called on an object, while the methods are executing and after the methods complete execution. 3. Instance variables starts its life only after a method is called on an object, and lasts till the method completes its execution.

2

Which one of the following symbols indicates a single line comment in Java application source code: 1. \\ 2. // 3. #! 4. ##

2

Which one of the following terms is correct for a Java class that creates object of another class, then calls the object's methods? 1. Abstract class 2. Driver class 3. Subscriber class. 4. Concrete class

2

Which statement about Constructors and static methods is true? 1. Constructors can be declared abstract but not static methods. 2. Neither constructors nor static methods can be declared abstract. 3. Both of them can be declared abstract. 4. Static methods can be declared abstract but not constructors

2

Which statement best describes an interface? 1. A public interface must be declared in a file with the same name as the interface and the .interface filename extension. 2. An interface is often used in place of an abstract class when there is no default implementation to inherit - that is, no fields and no default method implementations. 3. Unlike public abstract classes, interfaces are typically private types. 4. Allows objects of related classes to be processed polymorphically by responding to the same method calls.

2

Which statement best describes an interface? 1. Allows objects of related classes to be processed polymorphically by responding to the same method calls. 2. An interface is often used in place of an abstract class when there is no default implementation to inherit - that is, no fields and no default method implementations. 3. A public interface must be declared in a file with the same name as the interface and the .interface filename extension. 4. Unlike public abstract classes, interfaces are typically private types.

2

String-concatenation actually does one of the following: 1. modifies the original string and saves the string with the modified data. creates a new String object containing the concatenated values - the original 2. String objects are not modified. 3. replaces the original string and the original string gets deleted. 4. does not exist in Java programming language.

2.

A Composition is a capability that does one of the following: 1. allows you to use Java inheritance. 2. ensures Java Exception Handling. 3. allows a class to have references to objects of other classes as data members. 4. allows you to declare constants in a Java class.

3

What happens when you create a new class by inheriting the members of another existing class? 1. the existing class is called a sub-class. 2. No matter what, constructors are always inherited by the new class. 3. the new class inherits the default constructor only if you do not have a user-defined constructor in the existing class. 4. The new inherited class created is called a super class.

3

When the compiler encounters a method call made through a variable, the compiler determines if the method can be called by checking the variable's class type. This process is called as: 1. Hybrid binding 2. Blended binding 3. Dynamic binding 4. Static binding

3

Which of the following Java program units defines a group of related objects? 1. Java method 2. Java 3. Java Class 4. Java default constructor

3

Which of the following processes is typically used by JVM to execute bytecode? 1. Regular time compilation only 2. Interpretation 3. A combination of interpretation and just-in-time (JIT) compilation 4. Just-in-time (JIT) compilation

3

Which of the following statements about arrays in false? 1. Every array has an overridden clone method that copies the array. 2. If the array stores references to objects, the objects are not copied - a shallow copy is performed. 3. A shallow copy of an array cannot be made by simply copying the reference 4. A deep copy means actually creating a new array and copying over the values.

3

Which of the following statements is true about a static import declaration? 1. static import does not enable you to import all static members of a class (which is known as static import on demand) 2. none of the above statements is true. 3. static import enables you to import the static members of a class or interface so you can access them via their unqualified names in your class - that is, the class name and a dot (.) are not required when using an imported static member. 4. static import does not enable to import a particular static member

3 import graphics.Rectangle; Rectangle myRectangle = new Rectangle();

Which one of the following symbols indicates a multi-line comment in Java application source code? 1. ## 2. // \\ 3. /* */ 4. || ||

3.

Which of the following statements is false about final variables? 1. when final variables are declared by each of the class's constructors so that each object of the class has a different value. 2. A final variable cannot be modified by assignment after it's initialized. 3. If a class provides multiple constructors, none of the constructors would be required to initialize each final variable used within them. 4. If a final variable is not initialized, a compilation error occurs.

3. If a class provides multiple constructors, every one would be required to initialize each final variable.

To make efficient use of Exception Handling in Java, you must do the one of the following: 1. Only use one catch block 2. use finally block 3. use at least try and one catch block 4. Only use one try block

4

To overload a constructor, you would do one of the following: 1. simply provide multiple constructor declarations with different implementations. 2. simply provide multiple constructor declarations with different names./ 3. simply provide multiple constructor declarations with the same signatures. 4. simply provide multiple constructor declarations with different signatures.

4

Which of the following tools support the software-development process, including editors for writing and editing programs and debuggers for locating logic errors—errors that cause programs to execute incorrectly? 1. Java Virtual Machine (JVM) 2. Java Development Kit (JDK) 3. Java Integrated Development Envronments (IDE) 4. Java Application Programming Interfaces (API)

Java Integrated Development Envronments (IDE)

Which of the following editions of Java contains the capabilities needed to develop desktop and server applications? 1. Java Enterprise Edition 2 (Java 2 EE) 2. Java Micro Edition (Java ME) 3. Java Standard Edition 8 (Java SE 8) 4. Java Enterprise Edition (Java EE)

Java Standard Edition 8 (Java SE 8)

Java application programming interface (API) is a list of all classes that are part of the ____________ . It includes all _____ ______ .

Java application programming interface (API) is a list of all classes that are part of the Java development kit (JDK). It includes all Java packages

When a method that specifies a return type other than void is called, what must the method do when it completes its task? and completes its task, the method must return a result to its calling method. 1. It must return one result to the statement immediately after the method body. 2. It must return more than just one result to its caller. 3. It must return one result only to the statement one line after the line from which it was called. 4. It must return a result exactly to the point from which it was called.

4

Which of the following components does a Java application need to have at least one of? 1. Local variable 2. Non-static Method 3. Instance variable 4. Class

4

Which of the following statements is false in relation to Java parameters? 1. Parameters are declared in a comma-separated parameter list 2. Parameter names must follow the naming rules of identifiers. 3. Parameters are located inside the parentheses that follow the method name in the method declaration. 4. Parameters do not need to specify a datatype.

4

Which of the following statements is true about Java constructors? 1. You must create a user-defined constructor in all Java applications which would help to construct objects from a class. 2. You can make use of the default constructor supplied by the compiler without any additional code even if you declared user-defined constructor or constructors. 3. User-defined constructors may have any name of your choice as long as the name follows the naming rules of Java class. 4. User-defined constructors must not have a return type, not even a void.

4

Which of the following statements about final classes is false? 1. Making the class final also prevents programmers from creating subclasses that might bypass security restrictions. 2. Class String is an example of a final class. 3. All methods in a final class are implicitly final. 4. A final class can be extended to create a subclass.

4 public abstract void draw()

How many significant digits does a floating-point number have? 5 10 7 15

7

__________ nested classes are called inner classes. _______ classes that are declared static is called static nested classes.

Non-static nested classes are called inner classes. Nested classes that are declared static is called static nested classes.

The ______-_____ stack (sometimes referred to as the program-execution stack) is a data structure that works behind the scenes to support the method call/return mechanism. It also supports the creation, maintenance and destruction of each called method's local variables.

The method-call stack (sometimes referred to as the program-execution stack) is a data structure that works behind the scenes to support the method call/return mechanism. It also supports the creation, maintenance and destruction of each called method's local variables.

To access the _______ class, create an object of the outer class, and then create an object of the inner class:

To access the inner class, create an object of the outer class, and then create an object of the inner class:

module

a uniquely named, reusable group of related packages, as well as resources (such as images and XML files).

Random Number Generator

import java.security.SecureRandom; SecureRandom randomNumbers = new SecureRandom(); // pick random integer from 1 to 6 int face = 1 + randomNumbers.nextInt(6);

Scanner

import java.util.Scanner Scanner scanner = new Scanner(System.in); int num = scanner.nextInt(); String line = scanner.nextline()

enum type

public enum Day { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY } EnumTest firstDay = new EnumTest(Day.MONDAY);

Every object can access a reference to itself with one of the following keywords: 1. this 2. that 3. there 4. here

this

Downcasting

type cast to the type of a descendant class; We use downcasting whenever we want to access behaviors of the subtype

What is not supported by Java Inheritance? 1. hierarchical inheritance. 2. Multiple inheritance 3. single inheritance. 4. Multi-level inheritance.

2

Common Methods of the Object class

1. clone() 2. equal() 3. finalize() 4. getclass() 5. hashcode() 6. tostring()

How many significant digits does a double precision number have? 5 10 7 15

15

In which year did Sun Microsystems fund an internal corporate research project led by James Gosling, which resulted in a C++ -based object-oriented programming language that Sun called Java? 1. 1990 2. 1991 3. 1998 4. 1999

1991

A subclass in Java Inheritance is also one of the following: 1. can add its own fields cannot add its own methods. 2. represents a "is a" relationship in relation to its super class. 3. represents a "has a" relationship in relation to its super class. 4. In general, a subclass cannot be a superclass of future subclasses.

2

Finally block, if it exists does one of the following: 1. executes only if catch block(s) fail(s) to catch an exception. 2. always executes no matter whether the catch block(s) catch(es) exceptions or not. 3. executes only if catch block(s) catch(es) an exception. 4. executes only if there are more than one catch block.

2

How do you access a superclass's protected members? 1. the members of that superclass only. 2. The members of that superclass, by members of its subclasses and by members of other classes in the same package. 3. by members of other classes in the same package only. 4. only the members of its subclasses only.

2

In Java Inheritance, a subclass is one of the following: 1. is more general than its superclass and represents a more generalized group of objects. 2. can add behaviors that are specific to the subclass. 3. is more specific than its superclass and represents a more specialized group of objects. 4. does not exhibits the behaviors of its superclass.

2

A class in Java is a collection of ______ ______, which describe the properties of class objects, and _______, which describe the behaviors.

A class in Java is a collection of instance variables, which describe the properties of class objects, and methods, which describe the behaviors.

A nested class is a member of its enclosing class. __________ classes (inner classes) have access to other members of the enclosing class, even if they are declared _________.

A nested class is a member of its enclosing class. Non-static nested classes (inner classes) have access to other members of the enclosing class, even if they are declared private.

All Java platforms consist of a ________ and an ________

All Java platforms consist of a Java Virtual Machine (VM) and an application programming interface (API)

An object has attributes that are implemented as _____ _____ and carried with it throughout its lifetime.

An object has attributes that are implemented as instance variables and carried with it throughout its lifetime.

For any of the objects above you may distinguish some _____ and ______.

For any of the objects above you may distinguish some properties and behaviors.

stack overflow

If more method calls occur than can have their stack frames stored on the program-execution stack, an error known as a stack overflow occurs.

Polymorphism is particularly effective for implementing so-called _____ _____ systems.

Polymorphism is particularly effective for implementing so-called layered software systems. Example: Operating systems and device drivers.

What does an instance variable describe? 1. Behaviour of an object 2. Measurement of an object 3. Properties of an object 4. Height of an object.

Properties of an object

String objects in Java are _____ - they cannot be modified after they are created.

String objects in Java are immutable - they cannot be modified after they are created.

The ____ ____ platform provides an API and runtime environment for developing and running large-scale, multi-tiered, scalable, reliable, and secure network applications.

The Java EE platform provides an API and runtime environment for developing and running large-scale, multi-tiered, scalable, reliable, and secure network applications.

The Java _______ platform provides an API and a small-footprint virtual machine for running Java programming language applications on small devices, like mobile phones.

The Java Micro Edition (ME) platform provides an API and a small-footprint virtual machine for running Java programming language applications on small devices, like mobile phones. Java ME applications are often clients of Java EE platform services.

The Math class in the java._____ package provides methods and constants for doing more advanced mathematical computation.

The Math class in the java.lang package provides methods and constants for doing more advanced mathematical computation. e.g Math.cos(angle)

Access level modifiers

determine whether other classes can use a particular field or invoke a particular method. There are two levels of access control

Five Phases of Java Program

edit (editor), compile(Complier), load(Class Loader), verify (Bytecode Verifier) and execute (JVM)


Ensembles d'études connexes

CHAPTER 16: The Impact of Technology, Chapter 17: Delegating: Authority, Accountability, Responsibility in Delegation, Chapter 22: Person-centered Care, CHAPTER 24: Translating Research into Practice, Chapter 25 Managing Personal and Personnel proble...

View Set

Laboratory administration final exam

View Set

Walking Working Surface & Emergency Action Plans and Fire Protection

View Set

Ch 5: Life Insurance- Advanced Concepts

View Set

Ch. 13: Organizational, Political, and Personal Power

View Set

Hurst (Readiness Exam #4), Hurst (Readiness Exam #3)

View Set