Halaman

Monday, July 20, 2020

Section 2 Quiz Java Programming 2019 Learner - English

Section 2
(Answer all questions in this section)

Arrays have built-in operations including add, clear, contains, get and remove. True or false?


True


False (*)



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.


I and III only (*)


II and IV only


I, II, and III only


I, II, III and IV


None of these


Reading great code is just as important for a programmer as reading great books is for a writer. True or false?


True (*)


False


Assertions are boolean statements to test and debug your programs.
True or false?


True (*)


False


Methods can not throw exceptions.
True or false?


True


False (*)


What is exception handling?


If your program exits before you expect it to.


An error that occurs against the flow of your program.


When a file fails to open.


A consistent way of handling various errors. (*)


What is one step you must do to create your own exception?


Declare the primitive data type Exception.


Create a new class that implements Exception.


Create a new class that extends Exception. (*)


Exceptions cannot be created. They are only built in to Java.


When line 10 is executed, which method will be called?
1 class Account {
2 public void deposit(int amt, int amt1) { }
3 public void deposit(int amt){ }
4 }
5 public class CreditAccount extends Account {
6 public void deposit() { }
7 public void deposit(int amt) {}
8 public static void main(String args[]){
9 Account account = new CreditAccount();
10 account.deposit(10);
11 }
12 }


line 7 (*)


line 6


line 2


line 3


The instanceof operator allows you to determine the type of an object.
True or false?


True (*)


False


Java provides virtual method invocation as a feature and it doesn't require specialized coding.
True or false?


True (*)


False


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?


True (*)


False


The instanceof operator can find subclass objects when they are passed to method which declare a superclass type parameter.
True or false?


True (*)


False


Which two statements are equivalent to line 2?
(Choose Two)
1. public interface Account{
2. int accountID=100;
3. }

(Choose all correct answers)


protected int accountID=100;


Final int accountID=100; (*)


private int accountID=100;


static int accountID=100; (*)


Abstract int accountID=100;


Classes define and implement what?


Constants and all methods with implementations


All methods with implementations


Variables and methods (*)


Some methods with implementations


All method definitions without any implementations


You can only implement one interface in a class.
True or False?


True


False (*)

No comments:

Post a Comment

Final Exam Java Programming 2019 Learner - English

Final Exam