An array is an object that holds multiple methods true or false

An array is an object that holds multiple methods true or false

aisyahdian

Kamis, 30 November 2017

Java fundamental midterm

1. In Alice, objects inherit the characteristics of their:
Class (*)

2. A textual storyboard helps the reader understand the actions that will take place during the animation. True or false?
True (*)

3. In Alice, if a procedure is declared for a clownFish class, which classes can use the procedure?
ClownFish class (*)

4. Alice uses built-in math operators. They are:
All of the above (*)

6. You have a Class representing Cat. Each Cat can meow, purr, catch mice, and so on. When you create a new cat, what is it called?
An instance (*)

7. Which of the following statements about methods is false?
Classes must be defined directly within a method definition. (*)

8. From your Alice lessons, built-in functions provide precise property details for the following areas:
Proximity, size, spatial relation, and point of view. (*)

9. From your Alice lessons, what is the purpose of nesting?
To add visual structure to your program. (*)

10. Debugging is the process of finding bugs in a software program. True or false?
True (*)

11. A loop can be infinite (continue forever) or conditional (stops upon a condition). True or false?
True (*)

12. When you import a class from another file you have to import the entire class. True or false?
False (*)

13. To save a class to the myClasses directory you do so at the ________ level.
Class (*)

14. Which handle style would be used to rotate an object’s sub-part about the x, y, and z axes?
Rotation (*)

15. Which is an example of the Boolean variable type?
True or False (*)

16. In Java code the < >brackets are used to represent what statements?
(Choose all correct answers)
Begin(*)
End(*)

17. In Alice, which of the following is not a control statement?
Move (*)

18. In Alice, a computer program requires functions to tell it how to perform the procedure. True or false?
False (*)

19. In Alice, the setVehicle procedure will associate one object to another. True or false?
True (*)

20. In Alice, where are arithmetic operators available?
(Choose all correct answers)
Amount argument (*)
Duration argument (*)
Get Distance functions (*)

22. What is the purpose of a function in Alice?

To compute and answer a question about an object. (*)

23. Which of the following elements of the Alice animation should be tested before the animation is considered complete?
All of the above. (*)

24. The Alice animation should be tested throughout development, not just at the end of the animation’s development. True or false?
True (*)

25. To execute a method in your Greenfoot game, where is it called from?
The act method (*)

26. Which one of the following can be used to detect when 2 actors collide?
isTouching() (*)

27. The list below displays components of the Greenfoot source code editor except one. Which one
should be removed?
Instance creator (*)

28. From your Greenfoot lessons, where do you review a class’s inherited methods?
Documentation (*)

29. In Greenfoot, you must first create an instance before you create a class. True or false?
False (*)

30. Which of the following are examples of default superclasses that are present in a new Greenfoot scenario?
(Choose all correct answers)
World (*)
Actor (*)

31. Using the Greenfoot IDE, when is a constructor automatically executed?
When a new instance of the class is created. (*)

32. In Greenfoot, actor constructors can be used to create images or values and assign them to the variables. True or false?
True (*)

33. In Greenfoot, which method is used to add a new instance to a scenario when the world is initialized?
addObject (*)

34. When a Greenfoot code segment is executed in an if-statement, each line of code is executed in sequential order. True or false?
True (*)

35. From your Greenfoot lessons, which of the following comparison operators represents «greater than»?
>(*)

36. From your Greenfoot lessons, which axes define an object’s position in a world?
(Choose all correct answers)
Y(*)
X(*)

37. Which of the following comparison operators represents «greater than or equal»?
>= (*)

38. Which of the following features of Greenfoot will locate syntax errors in your program?
Compilation (*)

39. When designing a game in Greenfoot, it helps to define the actions that will take place in a textual storyboard. True or false?
True (*)

40. In Greenfoot, a local variable is declared at the beginning of a class. True or false?
False (*)

41. Which of the following is an example of string concatenation?
Instead of entering «.png» after each image file name, add + «.png» after the imageName value in the programming statement. (*)

42. In Greenfoot, when is a local variable most often used?
Within loop constructs (*)

43. An array is an object that holds multiple methods. True or false?
False (*)

44. In Greenfoot, you can only interact with the scenario using a keyboard.
False (*)

45. Greenfoot has tools to record sound. True or false?
True (*)

46. In Java what is casting?
When you take an Object of one particular type and turn it into another Object type. (*)

47. Using the Greenfoot IDE, only five instances can be added to a scenario. True or false?
False (*)

48. In Greenfoot, which of the following options are not possible when associating an image file with an instance?
Add a video (*)

49. In Greenfoot, methods can be called in the act method. When the Act button is clicked in the environment, the methods in the method body of the act method are executed. True or false?
True (*)

50. In the Greenfoot IDE, an instance’s position is on the x and y coordinates. True or false?
True (*)

1. In Alice, when using the getDistanceTo function what menu option would you use to subtract a set value from the distance?
Math (*)

2. From your Alice lessons, if you examined a science process that had many steps, which of the following is a way that you could apply functional decomposition to this process?

1. Identify the high level steps for the science concept.
2. Further refine and define the tasks needed for each high level step.
3. Present the problem as an animation. (*)

3. When presenting your Alice animation, it is not important to give the audience a reason to listen to the presentation. True or false?
False (*)

4. Identify an example of an Alice expression.
12 + 15 = 27 (*)

5. Alice uses built-in math operators; they are:
All of the above (*)

6. From your Alice lessons, what does the Count control statement do?
Executes statements a specific number of times. (*)

7. Which of the following is not a relational operator?
//(*)

8. In Java, which symbol is used to assign one value to another?
==(*)

9. When you import a class from another file you have to import the entire class. True or false?
False(*)

10. An event is any action initiated by the user that is designed to influence the programメs execution during play.
True(*)

11. What do lines 9 and 11 do in the following code
Accept user input and store them in the variables num1 and num2. (*)

12. Main is an example of what in the following code?

public static void main (String[] args) <
System.out.println <"Hello World!");
>
A method (*)

13. A flowchart is a useful way to illustrate how your Alice animation’s characters will look. True or false?
False (*)

14. From your Alice lessons, a flowchart could be created in a software program, or documented in a journal. True or false?
True(*)

15. From your Alice lessons, what does inheritance mean?
Each subclass inherits the methods and properties of its superclass. (*)

16. What do moving objects provide to your scene?
The action (*)

17. A conditional loop is a loop that will continue forever. True or false?
False (*)

18. Which of the following actions would require a control statement to control animation timing?
(Choose all correct answers)
A bird flying. (*)
A fish swimming. (*)
biped object walking. (*)

19. In Alice, which of the following is not a control statement?
Move (*)

20. In Alice, which control statement is used to invoke simultaneous movement?
Do Together (*)

What is Array Like Object in JavaScript

Before understanding what is Array like object, lets first have a look at what is an array and what is an object.

Object: Object are the Keyed Collection that hold the properties in key: value pair.
They are created with < >.
Example:

Exit fullscreen mode

we can access property as

Exit fullscreen mode

Exit fullscreen mode

So far so good.
let now have a look at what is an ARRAY LIKE OBJECT’

An array-like is an object
It has indexed access to the elements and a non-negative length property to know the number of elements in it. These are the only similarities it has with an array.
Doesn’t have any of the Array methods like, push, pop, join, map, etc.
Objects that have indexed properties and length are called array-like. Such objects may also have other properties and methods, but lack the built-in methods of arrays.

Array like object looks like:

Exit fullscreen mode

this is a object which looks like array.
Some Common examples of Array-like Objects are the arguments object in functions and HTMLCollection or NodeList objects returned from methods like document.getElementsByTagName or document.querySelectorAll

In Array like object we cannot access properties like we used to do in object.

Is an array an object in Java?

In Java we can declare an array using the following:

Does this mean that the array itself is an object? I ask, because in C++ an array is just a pointer and does not have any methods.

14 Answers 14

Trending sort

Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.

It falls back to sorting by highest score if no posts are trending.

Switch to Trending sort

The Java Language Specification section 4.3.1 starts off with:

An object is a class instance or an array.

An array is an object that holds multiple methods true or false. Смотреть фото An array is an object that holds multiple methods true or false. Смотреть картинку An array is an object that holds multiple methods true or false. Картинка про An array is an object that holds multiple methods true or false. Фото An array is an object that holds multiple methods true or false

An array is an object that holds multiple methods true or false. Смотреть фото An array is an object that holds multiple methods true or false. Смотреть картинку An array is an object that holds multiple methods true or false. Картинка про An array is an object that holds multiple methods true or false. Фото An array is an object that holds multiple methods true or false

Yes; the Java Language Specification writes:

In the Java programming language, arrays are objects (§4.3.1), are dynamically created, and may be assigned to variables of type Object (§4.3.2). All methods of class Object may be invoked on an array.

An array is an object that holds multiple methods true or false. Смотреть фото An array is an object that holds multiple methods true or false. Смотреть картинку An array is an object that holds multiple methods true or false. Картинка про An array is an object that holds multiple methods true or false. Фото An array is an object that holds multiple methods true or false

Well, let’s ask Java!

Yes, it is an object in Java.

Also note that when you do array.length you’re not invoking any methods but just accessing the array’s length field. There are plenty of static methods in the Arrays class.

An array is an object that holds multiple methods true or false. Смотреть фото An array is an object that holds multiple methods true or false. Смотреть картинку An array is an object that holds multiple methods true or false. Картинка про An array is an object that holds multiple methods true or false. Фото An array is an object that holds multiple methods true or false

It would be important to note that arrays in Java have their own byte codes which they do not share with objects. They are certainly Objects, but are handled slightly differently at the low level.

An array is an object that holds multiple methods true or false. Смотреть фото An array is an object that holds multiple methods true or false. Смотреть картинку An array is an object that holds multiple methods true or false. Картинка про An array is an object that holds multiple methods true or false. Фото An array is an object that holds multiple methods true or false

Arrays inherit all the members of java.lang.Object

or from an array type

8b. A unique reflection class instance (ie an instance of java.lang.Class ) is created for each different array type in your code. Examples

From the Java specification Section 4.3.1 Objects

An object is a class instance or an array.

A class instance is explicitly created by a class instance creation expression.

An array is explicitly created by an array creation expression.

The members of an array type are all of the following:

A clone of a multidimensional array is shallow, which is to say that it creates only a single new array. Subarrays are shared.

All the members inherited from class Object; the only method of Object that is not inherited is its clone method.

An array is an object that holds multiple methods true or false

An array is an object that holds multiple methods true or false. Смотреть фото An array is an object that holds multiple methods true or false. Смотреть картинку An array is an object that holds multiple methods true or false. Картинка про An array is an object that holds multiple methods true or false. Фото An array is an object that holds multiple methods true or false

An array is an object that holds multiple methods true or false. Смотреть фото An array is an object that holds multiple methods true or false. Смотреть картинку An array is an object that holds multiple methods true or false. Картинка про An array is an object that holds multiple methods true or false. Фото An array is an object that holds multiple methods true or false

Q1. Which core module in Node provides an API to register callbacks to track asynchronous resources created inside a Node.js application?

Q2. Which Node.js module should you use when you need to decode raw data into strings?

Q3. Which choice is not a valid method on event emitters?

Q4. What is the purpose of N-API?

to execute multi-threaded code in the Node environment

to insulate Addons from changes in the underlying JavaScript engine

to provide a quick way for users to create REST APIs

to allow users to make requests to the server

Q5. Which statement about event emitters is false?

Event names must be camelCase strings.

Any values returned by the listeners for an emitted event are ignored.

The emit method allows an arbitrary set of arguments to be passed to the listener functions.

When an event emitter object emits an event, all of the functions attached to that specific event are called synchronously.

Q6.How do you start a Node application, if the entry file is index.js?

Q7. Is it possible to write tests in Node.js without an external library?

yes, through the console module.

yes, through the debugger module.

Q8. How do you make an HTTP server object active and listen to requests on certain ports?

Q9. What does this code do?

It logs system information.

It creates a text file named hello.txt and appends customized text.

It creates a file named data and append numbers.

It creates an image file.

Q10. What is one way to install npm packages?

Q11. What is the purpose of the file system (fs) module?

to provide methods to work with databases.

to provide methods to work with files.

to add encryption to files.

to provide methods to work with requests and responses

Q12. What response will you get when you send a get request to the server with this code?

server running at port 3000

server running at http://localhost:4000/

server running at http://localhost:3000/

server running at http://127.0.0.1:3000/

Q13. How can you delay the execution of the function fn by at least one second?

Q14. What is the Node LTS version?

It is the version with the latest features.

It is an unstable version and is to be avoided.

It is the safest version for long-term support.

It is the version that will be retired soon.

Q15. When you run JavaScript in a Node.js application, which element in a Node.js stack actually executes that JavaScript?

the c-ares library

the libuv library

the VM (like V8 or Chakra)

the repl module

Q16. Is it possible to cluster multiple node processes?

yes, through the console module

yes, through the assert module

yes, through the cluster module

Q17. What is the purpose of the path module?

to provide utilities to test files

to make network requests

to provide utilities to play with file and directory paths

to provide utilities to add and remove filesto provide utilities to add and remove files

Q18.Which console method can be used to print the stack trace to the point of its execution?

Q19. Which of the following is a core module in Node?

Q20. Which special object is an instance of EventEmitter?

Q21. What is the shortest way to obtain the path name of the directory where your application is?

Q22. Which global object acts like a bridge between a Node script and the host operating system?

Q23. Which DNS module method uses the underlying OS facilities and does not necessarily perform any network communication?

Q24. Which choice is a method on the console object?

Q25. What command would you use to count the number of logical CPUs on the machine that is running Node?

Q26. If you run script.js with the following code, how do you access the value passed to VAR inside script.js?

Q27. Using ES6 imports, how would you import a module into a file?

npm install thisModule

const thismodule = require(./thismodule);

Q28. What module would you use to encrypt data?

Q29. Which object holds all arguments passed after executing a script with the node command?

Q30. Which choice is not a valid stream in Node?

Q31. Which assert module method is usually used to test the error-first argument in callbacks?

Q32. When a JavaScript function is invoked in Node, where is a new frame placed?

the events queue

Q33. Which line imports a promise-based version of the readFile method?

Q34. Which file does node-gyp use to read the build configuration of a module?

Q35. What is the use of require?

to load a module

to create an object literal

to create an application

to add a callback function to an object

Q36. What is the package manager that comes with Node.js?

Q37. Which library provides Node.js with the event loop?

Q38. What is one way to check that a value is a date object in Node?

Q39. Which CLI option can you use to debug a node script in Chrome DevTools?

Q40. Which object is used to manage the cache of required modules?

Q42. When a request event is received in the HTTP module, what is the type of the first argument passed to that event, usually named req?

Q43. You have a script.js file with the single line of code shown here. What will be the output of executing script.js with the node command?

ReferenceError: arguments is not defined

an empty string

an object representing an array that has five elements

Q44. If EventEmitter is in scope, which line of code will have an event emitter emitting a change event?

Q45. Which fs module method can be used to read the content of a file without buffering it in memory?

Q46. What can you export with module.exports?

only variables and arrays

functions, objects, arrays, or anything you assign to the module

Q47. What are the arguments passed to the module wrapper function?

exports, process, require, module, __filename, __dirname

exports, __filename, __dirname

exports, module, __filename, __dirname

exports, require, module, __filename, __dirname

Q48. How can you use the Promise API with a callback-based function such as child_process.exec?

Q49. Which choice is null a valid method on event emitters?

Q50. Which choice is not a Node repl command?

SAHABAT ALGORITMA

Minggu, 07 Mei 2017

OJP 1

1. Which of the following statements about unit testing is/are true

I. When all unit tests succeed, you can have high confidence your code is solid.
II. If a unit test fails, you don?t proceed until the code is fixed and the test succeeds.
III. Unit testing can help developer find problems early in the development cycle
Mark for Review
(1) Points

I only

II and III only (*)

2. Which of the following statements about arrays and ArrayLists in Java are true?

I. An Array has a fixed length.
II. An Array can grow and shrink dynamically as required.
III. An ArrayList can store multiple object types.
IV. In an ArrayList you need to know the length and the current number of elements stored.
Mark for Review
(1) Points

I and III only (*)

II and IV only

I, II, and III only

I, II, III and IV

None of these

3. Which of the following statements about inheritance is false? Mark for Review
(1) Points

A subclass inherits all the members (fields, methods, and nested classes) from its superclass.

Inheritance allows you to reuse the fields and methods of the super class without having to write them yourself.

Inheritance allows you to minimize the amount of duplicate code in an application by sharing common code among several subclasses.

Through inheritance, a parent class is a more specialized form of the child class. (*)

4. In the relationship between two objects, the class that is being inherited from is called the maxi-class. True or false? Mark for Review
(1) Points

True

False (*)

5. Which of the following is not a good technique to follow when reading code written by others? Mark for Review
(1) Points

Find the author of the code and ask him how it works. (*)

Learn the high level structure and starting point, and then figure out how it branches.

Build and run the code.

Perform testing.

Understand the constructs.

6. Examine the following code snippet. What is this an example of?

public class Car extends Vehicle <
public Car() <
.
>
> Mark for Review
(1) Points

Encapsulation

Polymorphism

7. Which two statements are access modifier keywords in Java?(Choose Two) Mark for Review
(1) Points

(Choose all correct answers)

protected (*)

abstract

public (*)

final

8. Which statements are true?(Choose Three) Mark for Review
(1) Points

(Choose all correct answers)

In a constructor, you can call a superclass constructor. (*)

You can declare more than one constructor in a class declaration. (*)

Since a constructor can not return any value, it should be declared as void.

A constructor can not be overloaded.

You can use access modifiers to control which other classes can call the constructor. (*)

9. You declare a method:
public void act(Student s)<>

Which of following arguments can be passed into the method? (Choose Two) Mark for Review
(1) Points

(Choose all correct answers)

Type of Object class

Interface

Type of Student class (*)

Type of the subclass of Student (*)

10. What is the output from the following code snippet?

public static void main(String[] args)<

List li=new ArrayList();
li.add(1);
li.add(2);
print(li);
>
public static void print(List list) <
for (Number n : list)
System.out.print(n + » «);
> Mark for Review
(1) Points

1

2

The code will not compile.

1 2 (*)

11. Examine the code below. Which statement about this code is true?

1.class Shape < >
2.class Circle extends Shape < >
3.class Rectangle extends Shape < >
4.class Node < >
5.public class Test <
6.public static void main(String[] args) <
7.Node nc = new Node<>();
8.Node ns = nc;
>
> Mark for Review
(1) Points

The code compiles.

An error at line 8 causes compilation to fail. (*)

An error at line 7 causes compilation to fail.

An error at line 4 causes compilation to fail.

12. The following code will compile.
True or False?

class Node implements Comparable <
public int compareTo(T obj)
>

class Test <
public static void main(String[] args) <
Node nc=new Node<>();
Comparable com=nc;
>
Mark for Review
(1) Points

True (*)

False

13. Which of the following correctly initializes an object named cell of the class Telephones whose generic type is Cellular? Mark for Review
(1) Points

Telephones cell = new Telephones(Cellular c);

Telephones(Cellular) cell = new Telephones(Cellular);

Telephones<> cell = new Telephones<>(Cellular c);

Telephones cell = new Telephones (); (*)

None of the these.

14. A HashMap can only store String types.
True or false? Mark for Review
(1) Points

True

False (*)

15. Nodes are components of LinkedLists, and they identify where the next and previous nodes are.
True or false? Mark for Review
(1) Points

True (*)

False

16. Implementing the Comparable interface in your class allows you to define its sort order.
True or false? Mark for Review
(1) Points

True (*)

False

17. A HashMap can store duplicates.
True or false? Mark for Review
(1) Points

True

False (*)

18. Stacks are identical to Queues.
True or false? Mark for Review
(1) Points

True

False (*)

19. Which of the following correctly defines a queue? Mark for Review
(1) Points

Something that enables you to create a generic class without specifying a type between angle brackets <>.

It is a keyword in Java that restrict the use of the code to local users only.

A list of elements with a first in last out order.

A list of elements with a first in first out order. (*)

20. Where you enqueue an element in the list? Mark for Review
(1) Points

removes it from the front of the list

adds it to the start of the list

adds it to the end of the list (*)

removes it from the end of the list

21. Which of the following describes a deque. Mark for Review
(1) Points

It is pronounced «deck» for short.

It implements a stack.

Allows for insertion or deletion of elements from the first element added or the last one.

All of the above. (*)

22. Which sort algorithm was used to sort the char array <'M', 'S', 'A', 'T', 'H'>?
The steps are shown below:

23. Big-O Notation is used in Computer Science to describe the performance of Sorts and Searches on arrays. True or false? Mark for Review
(1) Points

True (*)

False

24. Why might a sequential search be inefficient? Mark for Review
(1) Points

It utilizes the «divide and conquer» method, which makes the algorithm more error prone.

It requires incrementing through the entire array in the worst case, which is inefficient on large data sets. (*)

It involves looping through the array multiple times before finding the value, which is inefficient on large data sets.

It is never inefficient.

25. Which of the following sorting algorithms utilizes a «divide and conquer» technique to sort arrays with optimal speed? Mark for Review
(1) Points

Sequential Search

Merge Sort (*)

Selection Sort

Binary Search

All of the above

26. Why might a sequential search be inefficient? Mark for Review
(1) Points

It utilizes the «divide and conquer» method, which makes the algorithm more error prone.

It requires incrementing through the entire array in the worst case, which is inefficient on large data sets. (*)

It involves looping through the array multiple times before finding the value, which is inefficient on large data sets.

It is never inefficient.

27. A sequential search is an iteration through the array that stops at the index where the desired element is found. True or false? Mark for Review
(1) Points

True (*)

False

28. Bubble Sort is a sorting algorithm that involves swapping the smallest value into the first index, finding the next smallest value and swapping it into the next index and so on until the array is sorted.
True or false? Mark for Review
(1) Points

True

False (*)

29. Which of the following is the correct lexicographical order for the conents of the following int array?

30. Which of the following statements can be compiled?(Choose Three) Mark for Review
(1) Points

(Choose all correct answers)

List list = new ArrayList ();

List list = new ArrayList (); (*)

List list = new ArrayList (); (*)

List list = new ArrayList (); (*)

31. Which code inserted into the code below guarantees that the program will output [1,2]?
import java.util.*;
public class Example <
public static void main(String[] args) <
//insert code here
set.add(2);
set.add(1);
System.out.println(set);
>
> Mark for Review
(1) Points

Set set = new SortedSet();

Set set = new HashSet();

Set set = new TreeSet(); (*)

List set = new SortedList();

Set set = new LinkedHashSet();

32. Sets may contain duplicates.
True or false? Mark for Review
(1) Points

True

False (*)

33. ArrayList and Arrays both require you to define their size before use.
True or false? Mark for Review
(1) Points

True

False (*)

34. A HashSet is a set that is similar to an ArrayList. A HashSet does not have any specific ordering.
True or false? Mark for Review
(1) Points

True (*)

False

35. Which interface forms the root of the collections hierarchy? Mark for Review
(1) Points

java.util.Collections

java.util.Map

java.util.List

6. Unit testing is the phase in software testing in which individual software modules are combined and tested as a whole. True or false? Mark for Review
(1) Points

True

False (*)

7. What do Arrays and ArrayLists have in common?
I. They both store data.
II. They can both be traversed in loops.
III. They both can be dynamically re-sized during execution of a program.
Mark for Review
(1) Points

I only

II only

I and II only (*)

I, II and III only

None of these

8.Which of the following are important to your survival as a programmer? Mark for Review
(1) Points

Being good at reading code.

Looking for opportunities to read code.

Being good at testing.

All of these. (*)

9. Reading great code is just as important for a programmer as reading great books is for a writer. True or false? Mark for Review
(1) Points

True (*)

False

10. The instanceof operator allows you to determine the type of an object.
True or false? Mark for Review
(1) Points

True (*)

False

36. The following code is valid when working with the Collection Interface.
Collection collection = new Collection()d;
True or false? Mark for Review
(1) Points

True

False (*)

37. Which one of the following statements is true? Mark for Review
(1) Points

A Java program can only contain one super class

A class is a template that defines the features of an object (*)

A class is a Java primitive

A class is an intance of an object

38. An interfaces can declare public constants.
True or False? Mark for Review
(1) Points

True (*)

False

39. Immutable classes do allow instance variables to be changed by overriding methods.
True or false? Mark for Review
(1) Points

True

False (*)

40. In general, classes can be made immutable by placing a final key word before the class keyword.
True or false? Mark for Review
(1) Points

False

True (*)

41. Immutable classes can be subclassed.
True or false? Mark for Review
(1) Points

True

False (*)

42. The state of an object differentiates it from other objects of the same class.
True or False? Mark for Review
(1) Points

True (*)

False

43. A method with default access can be subclassed.
True or false? Mark for Review
(1) Points

True

False (*)

44. You can always upcast a subclass to an interface provided you don’t need to access any members of the concrete class.
True or false? Mark for Review
(1) Points

True (*)

False

45. Virtual method invocation occurs: Mark for Review
(1) Points

When the method of a subclass is used on a superclass reference. (*)

When the method of a superclass is used on a superclass reference.

When the method of a subclass is used on a subclass reference.

Not part of polymorphism.

46. The instanceof operator works with class instances and primitive data types.
True or false? Mark for Review
(1) Points

True

False (*)

47. Upward casting an object instance means you can’t access subclass specific methods.
True or false? Mark for Review
(1) Points

True (*)

False

48. Which two of the following statements are true? (Choose Two) Mark for Review
(1) Points

(Choose all correct answers)

An abstract class can create subclass and be constructed.

An abstract class must be difined by using the abstract keyword. (*)

An abstract class must contain abstrct method.

An abstract class can define constructor. (*)

49. Java provides virtual method invocation as a feature and it doesn’t require specialized coding.
True or false? Mark for Review
(1) Points

True (*)

False

50. The instanceof operator is a boolean comparison operator.
True or false? Mark for Review
(1) Points

True (*)

False

6. Unit testing is the phase in software testing in which individual software modules are combined and tested as a whole. True or false? Mark for Review
(1) Points

True

False (*)

7. What do Arrays and ArrayLists have in common?
I. They both store data.
II. They can both be traversed in loops.
III. They both can be dynamically re-sized during execution of a program.
Mark for Review
(1) Points

I only

II only

I and II only (*)

I, II and III only

8. Which of the following are important to your survival as a programmer? Mark for Review
(1) Points

Being good at reading code.

Looking for opportunities to read code.

Being good at testing.

All of these. (*)

9. Reading great code is just as important for a programmer as reading great books is for a writer. True or false? Mark for Review
(1) Points

True (*)

False

10. The instanceof operator allows you to determine the type of an object.
True or false? Mark for Review
(1) Points

True (*)

False

11. The instanceof operator is a boolean comparison operator.
True or false? Mark for Review
(1) Points

True (*)

False

12. Java provides virtual method invocation as a feature and it doesn’t require specialized coding.
True or false? Mark for Review
(1) Points

True (*)

False

13. The instanceof operator works with class instances and primitive data types.
True or false? Mark for Review
(1) Points

True

False (*)

14. What is the result of the following code snippet??

1. abstract class AbstractBankAccount <
2. abstract int getBalance ();
3. )
4. public class CreditAccount extends AbstractBankAccount <
5. private int balance;
6. private int getBalance () <
7. return balance;
8. >
9.> Mark for Review
(1) Points

An error at line 6 causes compilation to fail. (*)

Compilation is successful.

An error at line 2 causes compilation to fail.

An error at line 4 causes compilation to fail.

15. Virtual method invocation occurs when you try to call a superclass method.
True or false? Mark for Review
(1) Points

True

False (*)

16. Virtual method invocation occurs: Mark for Review
(1) Points

When the method of a superclass is used on a superclass reference.

When the method of a subclass is used on a subclass reference.

Not part of polymorphism.

When the method of a subclass is used on a superclass reference. (*)

17. Which of the following describes a deque. Mark for Review
(1) Points

It is pronounced «deck» for short

It implements a stack.

Allows for insertion or deletion of elements from the first element added or the last one.

All of the above. (*)

18. Why can a LinkedList be considered a stack and a queue?(Choose Three) Mark for Review
(1) Points

(Choose all correct answers)

Because you can remove elements from the end of it. (*)

Because you can remove elements from the beginning of it. (*)

Because you can not add element to the beginning of it.

Because you can add elements to the end of it. (*)

19. A LinkedList is a type of Stack.
True or false? Mark for Review
(1) Points

True (*)

False

20. Stacks are identical to Queues.
True or false? Mark for Review
(1) Points

True

False (*)

21. Which of the following is a list of elements that have a first in last out ordering. Mark for Review
(1) Points

Arrays

Stacks (*)

HashMaps

Enums

22. Which of the following correctly defines a queue? Mark for Review
(1) Points

A list of elements with a first in first out order. (*)

Something that enables you to create a generic class without specifying a type between angle brackets <>.

A list of elements with a first in last out order.

It is a keyword in Java that restrict the use of the code to local users only.

23. Which scenario best describes a queue? Mark for Review
(1) Points

A pile of pancakes with which you add some to the top and remove them one by one from the top to the bottom.

A row of books that you can take out of only the middle of the books first and work your way outward toward either edge.

A line at the grocery store where the first person in the line is the first person to leave. (*)

All of the above describe a queue.

24. What are maps that link a Key to a Value? Mark for Review
(1) Points

HashMaps (*)

ArrayLists

Arrays

HashSets

25. The local petting zoo is writing a program to be able to collect group animals according to species to better keep track of what animals they have.
Which of the following correctly defines a collection that may create these types of groupings for each species at the zoo? Mark for Review
(1) Points

public class
animalCollection <. >(*) (*)

public class
animalCollection(AnimalType T) <. >

public class
animalCollection <. >

public class
animalCollection(animalType) <. >

None of the these.

26. Enumerations (enums) are useful for storing data : Mark for Review
(1) Points

You cannot store data in an enum.

When the class is a subclass of Object.

When you know all of the possibilities of the class (*)

When the class is constantly changing

27. Generic methods are required to be declared as static.
True or False? Mark for Review
(1) Points

True

False (*)

28. is an example of a bounded generic wildcard.
True or False? Mark for Review
(1) Points

True

False (*)

29. Selection sort is a sorting algorithm that involves finding the minimum value in the list, swapping it with the value in the first position, and repeating these steps for the remainder of the list.
True or false? Mark for Review
(1) Points

True (*)

False

30. Which of the following best describes lexicographical order? Mark for Review
(1) Points

A simple sorting algorithm that is inefficient on large arrays.

An order based on the ASCII value of characters. (*)

A complex sorting algorithm that is efficient on large arrays.

The order of indicies after an array has been sorted.

31. Which of the following sorting algorithms utilizes a «divide and conquer» technique to sort arrays with optimal speed? Mark for Review
(1) Points

Sequential Search

Merge Sort (*)

Selection Sort

Binary Search

All of the above

32. Why might a sequential search be inefficient? Mark for Review
(1) Points

It utilizes the «divide and conquer» method, which makes the algorithm more error prone.

It requires incrementing through the entire array in the worst case, which is inefficient on large data sets. (*)

It involves looping through the array multiple times before finding the value, which is inefficient on large data sets.

It is never inefficient.

33. Bubble Sort is a sorting algorithm that involves swapping the smallest value into the first index, finding the next smallest value and swapping it into the next index and so on until the array is sorted.
True or false? Mark for Review
(1) Points

True

False (*)

34. Why might a sequential search be inefficient? Mark for Review
(1) Points

It utilizes the «divide and conquer» method, which makes the algorithm more error prone.

It requires incrementing through the entire array in the worst case, which is inefficient on large data sets. (*)

It involves looping through the array multiple times before finding the value, which is inefficient on large data sets.

It is never inefficient.

35.Of the options below, what is the fastest run-time? Mark for Review
(1) Points

n

n*log(n)

log(n) (*)

36. Which sort algorithm was used to sort the char array <'M', 'S', 'A', 'T', 'H'>?
The steps are shown below:

Sequential Search

Bubble Sort (*)

37. In general, classes can be made immutable by placing a final key word before the class keyword.
True or false? Mark for Review
(1) Points

False

True (*)

38. You can only implement one interface in a class.
True or False? Mark for Review
(1) Points

True

False (*)

39. Classes define and implement what? Mark for Review
(1) Points

All method definitions without any implementations

Constants and all methods with implementations

All methods with implementations

Some methods with implementations

Variables and methods (*)

40. Immutable classes can be subclassed.
True or false? Mark for Review
(1) Points

True

False (*)

41. Modeling classes for a business problem requires understanding of the business not Java. True or false? Mark for Review
(1) Points

True

False (*)

42. A method with default access can be subclassed.
True or false? Mark for Review
(1) Points

True

False (*)

43. Which two statements are equivalent to line 2?
(Choose Two) 1. public interface Account <
2. int accountID=100;
3. > Mark for Review
(1) Points

(Choose all correct answers)

static int accountID=100; (*)

private int accountID=100;

protected int accountID=100;

Abstract int accountID=100;

Final int accountID=100; (*)

44. What is a set? Mark for Review
(1) Points

A collection of elements that contains duplicates.

A collection of elements that does not contain duplicates. (*)

Something that enables you to create a generic class without specifying a type between angle brackets <>.

A keyword in Java that initializes an ArrayList.

45. Which of the following statements can be compiled?(Choose Three) Mark for Review
(1) Points

(Choose all correct answers)

List list = new ArrayList ();

List list = new ArrayList (); (*)

List list = new ArrayList (); (*)

List list = new ArrayList (); (*)

6. Choose the best definiton for a collection. Mark for Review
(1) Points

It is an interface in the java.util package that is used to define a group of objects. (*)

It enables you to create a generic class without specifying a type between angle brackets <>.

It is a special type of class that is associated with one or more non-specified Java type.

It is a subclass of List.

47. Sets may contain duplicates.
True or false? Mark for Review
(1) Points

True

False (*)

48. Which is the correct way to initialize a HashSet? Mark for Review
(1) Points

ClassMates = public class
HashSet();

classMates = new HashSet[String]();

HashSet classMates =
new HashSet(); (*)

String classMates = new
String();

49. Which interface forms the root of the collections hierarchy? Mark for Review
(1) Points

java.util.Map

java.util.Collection (*)

java.util.Collections

java.util.List

50. What is the result from the following code snippet?

interface Shape <>
class Circle implements Shape<>
class Rectangle implements Shape<>
public class Test <
public static void main(String[] args) <
List ls= new ArrayList ();//line 1
ls.add(new Circle());
ls.add(new Rectangle());// line 2
ls.add(new Integer(1));// line 3
System.out.println(ls.size());// line 4
> Mark for Review
(1) Points

3 (*)

Compilation error at line 1

Compilation error at line 4

Compilation error at line 2

Compilation error at line 3

1. Which statement is true when run the following statement?

2. A class can be extended by more than one class. True or False? Mark for Review
(1) Points

True (*)

False

3. Which two statements are access modifier keywords in Java?(Choose Two) Mark for Review
(1) Points

(Choose all correct answers)

public (*)

protected (*)

abstract

final

4. Unit testing can help you isolate problem quickly. True or False? Mark for Review
(1) Points

True (*)

False

5. Which statement is true for the class java.util.ArrayList? Mark for Review
(1) Points

The elements in the collection are ordered. (*)

The elements in the collection are accessed using key.

The elements in the collection are synchronized.

The elements in the collection are immutable.

6. The main purpose of unit testing is to verify that an individual unit (a class, in Java) is working correctly before it is combined with other components in the system. True or false? Mark for Review
(1) Points

True (*)

False

7. Which of the following statements about arrays and ArrayLists in Java are true?
I. An Array has a fixed length.
II. An Array can grow and shrink dynamically as required.
III. An ArrayList can store multiple object types.
IV. In an ArrayList you need to know the length and the current number of elements stored.
Mark for Review
(1) Points

I and III only (*)

II and IV only

I, II, and III only

I, II, III and IV

8. When an object is able to pass on its state and behaviors to its children, this is called: Mark for Review
(1) Points

Encapsulation

Isolation

Polymorphism

Inheritance (*)

9. Which of the following are important to your survival as a programmer? Mark for Review
(1) Points

Being good at reading code.

Looking for opportunities to read code.

Being good at testing.

All of these. (*)

10. Which of the following best describes lexicographical order? Mark for Review
(1) Points

A complex sorting algorithm that is efficient on large arrays.

An order based on the ASCII value of characters. (*)

The order of indicies after an array has been sorted.

A simple sorting algorithm that is inefficient on large arrays.

11. Of the options below, what is the fastest run-time? Mark for Review
(1) Points

n^2

log(n) (*)

n

n*log(n)

12. Selection sort is a sorting algorithm that involves finding the minimum value in the list, swapping it with the value in the first position, and repeating these steps for the remainder of the list.
True or false? Mark for Review
(1) Points

True (*)

False

13. A sequential search is an iteration through the array that stops at the index where the desired element is found.
True or false? Mark for Review
(1) Points

True (*)

14. Bubble Sort is a sorting algorithm that involves swapping the smallest value into the first index, finding the next smallest value and swapping it into the next index and so on until the array is sorted.
True or false? Mark for Review
(1) Points

True

False (*)

15. Which of the following is the correct lexicographical order for the conents of the following int array?

16. Why might a sequential search be inefficient? Mark for Review
(1) Points

It utilizes the «divide and conquer» method, which makes the algorithm more error prone.

It requires incrementing through the entire array in the worst case, which is inefficient on large data sets. (*)

It involves looping through the array multiple times before finding the value, which is inefficient on large data sets.

It is never inefficient.

17. A sequential search is an iteration through the array that stops at the index where the desired element is found. True or false? Mark for Review
(1) Points

True (*)

False

18. In general, classes can be made immutable by placing a final key word before the class keyword.
True or false? Mark for Review
(1) Points

True (*)

False

19. Immutable classes can be subclassed.
True or false? Mark for Review
(1) Points

True

False (*)

20. Classes define and implement what? Mark for Review
(1) Points

Some methods with implementations

All methods with implementations

All method definitions without any implementations

Variables and methods (*)

Constants and all methods with implementations

21. Interfaces define what? Mark for Review
(1) Points

Constants and all methods with implementations

Variables and methods

Some methods with implementations

All method definitions without any implementations (*)

All methods with implementations

22. Making a class immutable means: Mark for Review
(1) Points

That it cannot be extended. (*)

To create an instance of the class.

To create a sub class from a parent class

That it is directly subclassed from the Object class

23. Modeling classes for a business problem requires understanding of the business not Java. True or false? Mark for Review
(1) Points

True

False (*)

24. Modeling business problems requires understanding the interaction between interfaces, abstract and concrete classes, subclasses, and enum classes. Mark for Review
(1) Points

True (*)

False

25. Which method will force a subclass to implement it? Mark for Review
(1) Points

Public native double act();

Abstract public void act(); (*)

Protected void act(String name)<>

Static void act(String name) <>

Public double act();

26. Virtual method invocation occurs when you try to call a superclass method.
True or false? Mark for Review
(1) Points

True

False (*)

27. Virtual method invocation must be defined with the instanceof operator.
True or false? Mark for Review
(1) Points

True

False (*)

28. A upward cast means all instance variables of the subclass are permanently lost to the instance.
True or false? Mark for Review
(1) Points

True

False (*)

29. Calling a subclass method by referring to a superclass works because you have access to all specialized methods through virtual method invocation.
True or false? Mark for Review
(1) Points

True

30. Which line contains an compilation error?

interface Shape <>
interface InnerShape extends Shape<>
class Circle implements Shape< >
class InnerCircle extends Circle<>
class Rectangle implements Shape<>
public class Tester <
public static void main(String[] args) <

Circle c= new Circle();
InnerCircle ic = new InnerCircle();
Rectangle rect = new Rectangle();

System.out.print(c instanceof InnerCircle); //Line 1
System.out.print(ic instanceof Circle); //Line 2
System.out.print(rect instanceof InnerCircle); //Line 3
System.out.print(rect instanceof Shape); //Line 4
>
> Mark for Review
(1) Points

Line 1

Line 3 (*)

Line 4

Line 2

31. Which two of the following statements are true? (Choose Two) Mark for Review
(1) Points

(Choose all correct answers)

An abstract class must be difined by using the abstract keyword. (*)

An abstract class can define constructor. (*)

An abstract class must contain abstrct method.

An abstract class can create subclass and be constructed.

32. Which interface forms the root of the collections hierarchy? Mark for Review
(1) Points

java.util.Collection (*)

java.util.Map

java.util.List

java.util.Collections

33. Which of the following correctly adds «Cabbage» to the ArrayList vegetables? Mark for Review
(1) Points

vegetables[0] = «Cabbage»;

vegetables += «Cabbage»;

vegetables.add(«Cabbage»); (*)

vegetables.get(«Cabbage»);

34. What is the result from the following code snippet?

interface Shape <>
class Circle implements Shape<>
class Rectangle implements Shape<>
public class Test <
public static void main(String[] args) <
List ls= new ArrayList ();//line 1
ls.add(new Circle());
ls.add(new Rectangle());// line 2
ls.add(new Integer(1));// line 3
System.out.println(ls.size());// line 4
> Mark for Review
(1) Points

Compilation error at line 4

Compilation error at line 1

Compilation error at line 2

3 (*)

Compilation error at line 3

35. What is the output from the following code snippet?

Integer[] ar = <1, 2, 1, 3>;
Set set = new TreeSet (Arrays.asList(ar));
set.add(4);
for (Integer element : set) <
System.out.print(element);
> Mark for Review
(1) Points

1234 (*)

1213

11234

12134

36. Which of the following statements can be compiled?(Choose Three) Mark for Review
(1) Points

(Choose all correct answers)

List list = new ArrayList (); (*)

List list = new ArrayList (); (*)

List list = new ArrayList ();

List list = new ArrayList (); (*)

37. A HashSet is a set that is similar to an ArrayList. A HashSet does not have any specific ordering.
True or false? Mark for Review
(1) Points

True (*)

False

38. Which class is an ordered collection that may contain duplicates? Mark for Review
(1) Points

enum

array

set

list (*)

39. A generic class is a type of class that associates one or more non-specific Java types with it.
True or False? Mark for Review
(1) Points

True (*)

False

40. Generic methods can only belong to generic classes.
True or False? Mark for Review
(1) Points

True

False (*)

41. What is the output from the following code snippet?

public static void main(String[] args)<

List li=new ArrayList();
li.add(1);
li.add(2);
print(li);
>
public static void print(List list) <
for (Number n : list)
System.out.print(n + » «);
> Mark for Review
(1) Points

The code will not compile.

42. An example of an upper bounded wildcard is. Mark for Review
(1) Points

ArrayList

ArrayList

ArrayList

ArrayList (*)

43. Implementing the Comparable interface in your class allows you to define its sort order.
True or false? Mark for Review
(1) Points

True (*)

False

44. A LinkedList is a list of elements that is dynamically stored.
True or false? Mark for Review
(1) Points

True (*)

False

45. Why can a LinkedList be considered a stack and a queue?(Choose Three) Mark for Review
(1) Points

(Choose all correct answers)

Because you can not add element to the beginning of it.

Because you can remove elements from the end of it. (*)

Because you can add elements to the end of it. (*)

Because you can remove elements from the beginning of it. (*)

46. The Comparable interface includes a method called compareTo.
True or false? Mark for Review
(1) Points

True (*)

False

47. Which of the following methods adds a Key-Value map to a HashMap? Mark for Review
(1) Points

remove(Key, Value)

get(Key, Value)

48. Which scenario best describes a queue? Mark for Review
(1) Points

A pile of pancakes with which you add some to the top and remove them one by one from the top to the bottom.

A row of books that you can take out of only the middle of the books first and work your way outward toward either edge.

A line at the grocery store where the first person in the line is the first person to leave. (*)

All of the above describe a queue.

49. A LinkedList is a type of Stack.
True or false? Mark for Review
(1) Points

True (*)

False

50. Which of the following describes a deque. Mark for Review
(1) Points

It is pronounced «deck» for short.

It implements a stack.

Allows for insertion or deletion of elements from the first element added or the last one.

All of the above. (*)

Источники информации:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *