Java Level 1 Certification

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

The properties of an object are implemented using methods, and the behavior is implemented using variables.

False

Multi-line comments start with */ and end with /*

False, /**/ is a multi-line comment

End-of-line comments start with ///

False, // is an end-of-line comment

An class can have a static modifier only if it is an outer class.

False, A class can only be static if it is an inner class.

A comment cannot appear before, within and after a method definition.

False, A comment can appear anywhere it pleases

A comment cannot appear before and after a package statement.

False, A comment can appear anywhere it pleases.

A class constructor cannot be used to create and initialize the objects of a class.

False, A constructor is used to create and initialize objects.

A while statement only needs a value as a parameter to ensure that the statements get executed

False, A while loop parameter must be an expression that evaluates to true or false or it must be the values true or false explicitly written.

An abstract class must have either all fully defined abstract methods or just abstract methods with no definition

False, An abstract class can have any number of abstract and non-abstract methods. The abstract methods can't be defined.

An abstract interface's methods must all be undefined.

False, An interface can contain a defined static method, a defined default method, or an undefined non-abstract method and an undefined abstract method.

Comments come in two types: multi-line comments and block comments.

False, Comments can be multi-line or end-of-line

An abstract method can be defined in a non-abstract class?

False, If a method in a class is abstract then the class must have the abstract modifier.

A single catch block can handle only one type of exception

False, In Java SE 7 and higher simply separate the exceptions in the argument with |

Exception handling does not separate the code that handles errors from the program logic.

False, It does separate the error code from the program logic.

A single copy of a class variable or static variable isn't shared by all the objects of a class.

False, It is shared by all the objects of a class.

The public access modifier scope is not visible everywhere

False, It is visible everywhere.

An exception that appears while the programming is running is called a checked exception

False, It's a runtime exception

The protected access modifier has scope only within the subclasses.

False, Protected has scope within the package and all sub classes

RuntimeException and Error exceptions class and its subclasses are subject to the Catch or Specify Requirement.

False, The Catch or Specify Requirement don't apply to unchecked exceptions.

int [] sampleArray = new int [10]; Is the sampleArray.length = 9?

False, The length is 10.

All abstract methods of an abstract class that is extended to another abstract class don't need the abstract in its method header.

False, The method header should be the exact same as the method header of the class from which you are extending it from.

The package statement can appear within a class declaration or after the class declaration

False, The package statement must be before the class declaration and can only have a comment before it.

Are these non access modifiers in Java: default, public, protected, private

False, These are access modifiers

All exceptions are unchecked exceptions, except for those indicated by Error, RuntimeException, and their subclasses.

False, They are checked exceptions

char [] first = new char [5]; first = {'0','1','2','3','4'}; Will this produce 01234?

False, This will not compile. You can only initialize each array index after it has been declared this way.

int a = 2; String b = "conditional"; if(b.charAt(a) > b.charAt(a+1) Will 'd' be printed out?

False, Yes, n > d but 'n' will be printed out not 'd'

You can't extend an abstract class to another abstract class.

False, You can

You can't create a variable using the name of a class that is abstract

False, You can create a variable with an name of a class that is abstract.

You can have more than one package statement in a class.

False, You can only place a class in one package.

A class has to be defined in a package.

False, You don't have to put a class in package, but it will automatically be placed in the default package for you if you don't explicitly name one

To use a class or an interface from another package, you do not use its fully qualified name.

False, You have to use the fully qualified name unless you import the package that contains the class or interface.

A method parameter can use only one data type for all its variables. For example public int name(String firstName, LastName)

False, You need to explicitly write each data type: public int name(String firstName, String LastName)

int [] figure = new int [10][20]; Multidimensional array syntax?

False, You need two square brackets: int [][] figure = new int [10][20];

You need to create an object of a class if you want to invoke a method of that class within another method within the same class.

False, You will simply use the method because of the understood this as the object.

A class must be defined with an access modifier as such: public class Person{}

False, a class only needs: class Person {}

double [] score = new [10]; Is this how you declare an array?

False, double [] score = new double [10];

You can only have one catch block?

False, each catch block argument will list the type of exception you are handling.

String[][] multiArray = new String[4][5]; for(String [][] a : multiArray) { Arrays.fill(a, "testing"); } This is how you fill a multidimensional array?

False, for(String [] a : multiArray) { Arrays.fill(a, "testing"); } Only one square bracket is needed.

An abstract interface class can't include any variables.

False, it can have constant variables.

The equals method is used to compare whether two references point to the same location in memory.

False, it checks whether the values stored in two objects are the same and if the those values are the same then it will use the first value of an if else statement because it's true

If a catch block handles more than one exception type, then the catch parameter has to be explicitly defined as final.

False, it is implicit that the parameter ex in this case is final meaning you can't assign a value to it. catch (IOException|SQLException ex)

When you pass a primitive value, the value will be changed only if you create an object and call the method of the class that changes that value.

False, it is pass by value only and it will only be changed within the method and upon exiting the method it returns to its original value.

AnnualExam is defined in the package university and will access the class ExamQuestion in the certification package by using import ExamQuestion.certification.

False, it should be certification.ExamQuestion

int [] sampleArray = new int [10]; Is the last index 10?

False, the last index is 9.

3/2 = 1.5

False, the number will be truncated so the answer is 1

public static void main( String args...) This will compile and is acceptable?

False, the signature is incorrect : public static void main( String... args) is acceptable though

An abstract class method must have a complete definition?

False, their methods don't have to be fully defined.

An checked exception is an exception that is thrown because of incorrect use of the API such as the NullPointerException.

False, this is a unchecked exception that derives from the RuntimeException class. It is unchecked because you don't have to explicitly check for it.

String [] array = new String []; You can use this if you don't know the array size.

False, you must always specify an array size: String [] array = new String [5];

5%2 = 1

True

A class can define multiple constructors that accept different sets of method parameters.

True

A class can have a static modifier only if it is a nested inner class.

True

A class is a design from which an object can be created.

True

A class is a design used to specify the properties and behavior of an object.

True

A class method or static method is used to work with the static variables.

True

A comment can appear anywhere.

True

A comment can appear before and after the class definition.

True

A parent class has a method that throws an exception. Therefore, the overridden method in the subclass must have the same type of exception handler, or the parent class can have an exception type that is a parent of the exception in the subclass.

True

A user can recover from all exceptions of the Exception class and its subclass, but not for those indicated by Error, RuntimeException, and their subclasses.

True

An end-of-line comment can be placed in multi-line comment.

True

An unchecked exception is an exception that is thrown because of incorrect use of the API such as the NullPointerException.

True

Are these components of a class declaration: public final class Runner extends Person implements Athlete

True

Are these non access modifiers in Java: Final, Static, Transient, Synchronized, Volatile

True

Arrays.fill(a, 0, 2, 3); a represent the array to be filled 0 represent the starting index 2 - starting index is places to be filled 3 represent the number to be filled Will the output be? 3 3 0 0 0 3 3 0 0 0 3 3 0 0 0 3 3 0 0 0

True

Arrays.fill(a, 2, 5, 3); a represent the array to be filled 2 represent the starting index 5 - starting index is places to be filled 3 represent the number to be filled Will the output be? 0 0 3 3 3 0 0 3 3 3 0 0 3 3 3 0 0 3 3 3

True

At least 75 to pass is the same as if(score >=75){

True

Classes and interfaces in the same package can use each other without prefixing their names with the package name.

True

Exception handlers can do more than just print error messages or halt the program. It can prompt the user to make a decision, or propagate the error up to a higher-level handler using chained exceptions.

True

Exception handling facilitates grouping and differentiating error types for easier handling.

True

If a class is abstract, you can create a method that has a parameter with that class name?

True

If a package statement is present in a class, the import statement must follow the package statement.

True

If extend an abstract class to another abstract class, you only need to list the abstract methods

True

If you have an abstract class, its subclasses must include all abstract methods even if they are not defined.

True

In a switch statement, each case will be executed until it reaches a break statement

True

Multi-line comments span multiple lines of code.

True

Nullpointer values and divide by zero errors are Runtime Exceptions

True

Private : Private has scope only within the classes

True

Setting an object of a parent class equal to and object of a subclass is possible but not the other way around

True

The == operator is used to compare if two references point to the same location in memory

True

The default access modifier has scope only inside the same package

True

The import statement follows the package statement but precedes the class declaration.

True

The use of an asterisk (*) to start the comment in the next line of a multi-line comment is not needed.

True

When you pass an object as parameter, and the object is modified within the method with no print statement, upon exiting that method the print statement that uses that object will use the modified object?

True

You can include an invocation of an abstract method within a non-abstract method.

True

You can use the import statement to use the simple name of a class or interface from a different package in your code.

True

You can't create an object of an abstract class.

True

You can't use the word Class to define a class in java.

True

Your code will fail to compile, if you place the package statement within the class definition.

True

boolean b = false; if (!b) {...} Will the code ... be executed

True

char [] first = new char [5]; first [0] = '0'; first [1] = '1'; first [2] = '2'; first [3] = '3'; first [4] = '4'; Will this produce 01234?

True

char [] first = {'0','1','2','3','4'}; Will this produce 01234?

True

char [] letter = {'a', 'b', 'c'}; Is this how you fill an array?

True

char [][] a = new char [5][12]; Means 0-4 down (row) and 0-11 across (column)

True

for( ; ; ) is an infinite loop, you can only use a break statement to end this loop.

True

for(String c: b){ System.out.print(c + " "); } Will this foreach loop output the value that is in b?

True

int [] sampleArray = new int [10]; Is the first index 0?

True

int a = 2; String b = "conditional"; if(b.charAt(a) > b.charAt(++a)

True

int[][] multiArray = new int[4][5]; for(int[] a : multiArray) { Arrays.fill(a, 0, 2, 3); } Will fill the first two columns?

True

new Employee().empName can be used to invoke a public nonstatic variable named empName in a class named Employee

True

public static void main( String args []) This will compile and is acceptable?

True


Kaugnay na mga set ng pag-aaral

Chapter 13 Culture and Diversity

View Set

Web Final (Ch.5-ch.11) (No chapter 9)

View Set

Ch. 11-The Strategy of International Business

View Set

Computer Maintenance Chapter 4 Part 2 Troubleshooting

View Set

Biology Final Quiz Questions ch 16-18 (evolution)

View Set

PHY 101: Exam 1 Quiz Questions Review

View Set

Chemistry - Nuclear Chemistry Test Review

View Set

Psychology (WEEK 1 - WEEK 6, MID TERM)

View Set

Life Insurance - Individual Life Insurance Contract // Provisions and Options

View Set