Programming Grade 11 (PROG-111) Week 11-20 Exams and Quizzes
AMALEAKS ANSWERJava Programming Quiz
Observe the following statements and decide whether the variable result’s value is TRUE or FALSE. Given that: int x = -77; int z = 43; result = (z < x && 1 != 10) ? true : false; result = (z != 43) ? true : false;
True or False: The last line of code, with a close brace { symbol, is properly indented.
True or False: Brackets [] are also separators used in declaring arrays.
Refer to the block of codes below. Read each statement carefully and decide whether it’s TRUE or FALSE. There is an error in line 9.
True or False: Operators, in Java programming language, use special symbols to call methods and their objects.
Read each statement carefully and decide whether it’s TRUE or FALSE. There are no errors in the program.
Refer to the block of codes below. Read each statement carefully and decide whether it’s TRUE or FALSE. Line 9 uses a traditional comment which uses double forward slash.
True or False: Many programmers can be literate with Java programming language for it is intended to be that way.
True or False: You’ll know there’s an error if you see a red circle with an exclamation point in Netbeans IDE.
Observe the following statements and decide whether the variable result’s value is TRUE or FALSE. Given that: int x = -77; int z = 43; result = (z < x && 1 != 10) ? true : false; result = (x = 100) >= z;
The file is accurately named – Students.java.
There are three (3) separators found in line 13.
There is an error in line 9.
result = 90 < x || -1 < z;
The last line of code, with a close brace { symbol, is properly indented.
Assuming there are no errors in the code, line 13 would display When I graduate, I’d be 18.
Figure 2 shows the Netbeans Integrated Development Environment.
The last line of code will output 100.0.
True or False: An exclamation point in Java means NOT. Therefore, != means not equal to.
There are two types of comments used in the program above – end of line and Javadoc comments.
result = (z < x && 1 != 10) ? true : false;
There are keywords found in line 7.
In line 11, the value of personage is 18.
If there are no errors in the program, the first line of output would read Hi, I’m a normal person.
result = (x * z + (z += 7)) >= 100;
True or False: Logical OR operator will result to false if one of the expressions is false.
True or False: Semicolon (;) is a separator used to end a Java statement.
True or False: There are five types of integer data types – byte, short, int, long and float.
True or False: Single equal sign (=) is used for assigning values while double equal sign (==) is used in comparing values.
True or False: Java’s ternary operator is a short hand for the if-then-else statement which uses a question mark and a colon.
True or False: JDK or Java Design Kit is required to compile and run Java apps and applets.
On line 6, average is equal to 0. But on line 9, average will be equal to 100.
True or False: Identifiers in Java are, in simple words, name that you give to Java class, variables and methods.
True or False: When you run javac in a command line interface, it will automatically create another file with a filename extension .class.
Line 9 uses a traditional comment which uses double forward slash.
There are five (5) separators used in line 8.
There are no errors on line 8.
True or False: Syntax is basically the spelling and grammar errors compiled in a Java programming language. It should be avoided in writing apps and applets.
True or False: Operators, in Java programming language, use special symbols to call methods and their objects.
If you run this program, the second line of output will read Your score is:.
True or False: Java is a low level programming language.
There are also punctuators used in line 10, in between System, out and println, the parentheses and semicolon.
If there are no errors and this simple program runs through CLI, the first line will display: Hi, students!
True or False: Brackets [] are also separators used in declaring arrays.
Substrings can contain 1 or 2 arguments.
Determine the output. [String manipulation]
The index of the letter “y” in string “Doggy” is 5.
Determine the output. [String manipulation]
True or False: The value “val_3” is a white space “ “.
True or False: Variable 1st_num is a good variable name in Java programming.
True or False: “val_2” contains “The”.
True or False: Instance variables are declared inside a method but outside a class.
True or False: Variable names in Java are not necessarily case sensitive.
Determine the output. [Arithmetic operation]
True or False: Public, private and protected are some of the return types used in Java programming.
True or False: Divide and conquer strategy, in programming, is also known as the top-down design.
If there are no errors in the program, line 9 would display I weigh 160.
True or False: A boolean variable can only have two values; it is either true or false.
result = !((x * 10) < z);
result = -(-z) == 43;
True or False: If you get an error while running the javac command in the CLI, it could be resolved by editing the Path value in Environment Variables.
True or False: The subtraction assignment operator subtracts the left and right operand and assigns the difference to the operand at the right.
x += x; result = x == 154;
The second line of output will be: You are in Year 11.
True or False: The conditional AND operator uses two ampersand (&&) symbols.
result = 43 <= z;
True or False: You’ll know that a variable is a class variable when you see that variable inside a class with the word static.
The string method “length( )” returns the number of characters within a string.
A string can contain numbers.
True or False: This is an example of concatenation.
True or False: The value of “val_4” is “fox”.
True or False: “val_2” contains “The”.
Determine the output. [String manipulation]
Languages which use procedural programming include C, (Answer) FORTRAN, Pascal and BASIC.
True or False: Local variables are declared inside the default method.
Strings can be declared with str.
True or False: Procedural programming involves instructing the system as to how to complete a task.
True or False: The output of this code is “The quick brown fox”.
Among the expressions below which is a statement?
Expressions can be long and complex.
number++; is an expression.
For-loops has a set number of iterations before starting.
The equals( ) method can compare more than 2 arrays.
While loops can use Booleans at test expressions.
The test expression of the if statement is _______.
There are four (4) major features of an object-oriented programming language – encapsulation, inheritance, polymorphism and abstraction.
Using a break; statement causes the loop to jump to the next iteration.
x+1 is example of a statement.
number++; is a block.
Arrays are
The operator “new” allocates a memory block the size of what is declared.
A class block can be an expression.
Statements can be expressions.
Integer arrays can be populated with characters.
Declaration clauses are declared as “number + 1”.
Loops can be stopped with a break; statement.
The equivalent of Paragraphs in coding is?
If statements cannot be nested in switches.
The length( ) method returns the size (number of indices) has.
When polymorphism is used, the Java object can only take one form. Subclasses should have the same function with the parent class.
Arrays can contain (Answer) number of elements.
“||” and “&&” can be used in conditional statements.
A class statement has three (3) major parts – declaration, initialization and instantiation.
Declaring an object in Java uses the new keyword to create a new object.
Please refer to Figure 2 to answer the question below: If the expression “num = 0” is changed to “num = 5” the final output will be
Expressions can be statements.
Blocks can contain more blocks of code.
If-else statements can be nested in?
Statements are equivalent to paragraphs.
A (answer) array is an array containing true or false values.
Switches are always used with if-else statements.
True or False: The modulus operator returns the remainder of a division operation instead of the quotient.
Determine the output. String val_1 = “564298”;
Determine the output. String val_1 = “35”;
The return value of the length( ) method is an integer.
A superclass is also known as a parent class.
For-loops can be nested in while loops.
In instantiating an object, the keyword instance is used.
Object oriented programming utilizes the top down method.
Expressions are like clauses.
The sort( ) method is always ascending.
Arrays are data types.
Variables must be declared as (Answer) for it to be fully hidden.
While statements check the test expression at the end.
The else statement can be used alone.
The fill( ) method (Answer) the array with specific values.
The output of println is
The person’s weight is declared correctly with the correct data type (byte) and value (160).
Determine the output. String val_1 = “foo”; String val_2 = “bar”; val_2 = val_1; val_1 = val_3; System.out.println(val_1);
Determine the output. String val_1 = “foo”; String val_2 = “bar”; val_2 = val_1; val_1 = val_3; System.out.println(val_2);
Switches can work properly even without the “break” expression.
Blocks can be one liner or huge classes.
The test expressions in conditional statements can be left empty.
Abstraction works by hiding the implementation details and showing only the functions necessary.
A single array can hold multiple data types.
A polymorphic object can pass more than one Is-a test.
Another loop can be used as test expression.
True or False: Public, static and void are sample of Java reserved keywords.
The value of “pStr” in line 24 is
The default syntax of a constructor is <class_name>(parameter, parameter){ }
A nested class is not an inner class.
Nested classes causes them to become abstracted.
A nested class is also called
If you want some variables and methods hidden from other classes, you could implement encapsulation where these variables and methods are wrapped in a single unit.
A constructor can only have 1-2 overloads or parameters.
All possible data types of an array can be returned as a string by the toString( ) method.
Abstracted classes can contain 1 or more abstract methods.
Abstraction shows the every bit of detail and implementation on how an application does something.
Initialization is a process where the constructor is called for.
The default syntax of a constructor is <class_name>( ){ }
Classes cannot be nested.
Abstract classes cannot have nested classes.
The parent class of a nested class is called an outer class.
An inner class can be constructed directly without reference to the outer class.
Arrays can be read backwards.
A single array can hold
Abstracted methods already have implementations inside.
are special methods to initialize objects.
Constructors have 3 basic rules to follow.
Nesting classes increases encapsulation.
Each index can only contain (Answer) element.
The sort( ) method can be set to sort only a part of an array.
Subclasses or child classes could have different behaviors but still share the same functions from their parent class.
Abstract methods must have an explicit return value.
An abstract class must not contain abstract methods.
Abstracted classes can be nested.
A subclass constructor cannot invoke a superclass constructor.
A class acquiring fields and methods of another class is called inheritance.
Parallelsorting utilizes
method can copy one array to another.
Conditional test expressions can contain declarations.
A child class inherits all the methods of every other class.
If the value of “pStr” in line 7 is changed to _______ then the value of “pStr” in line 24 will be changed as well.
The type of loop that checks the test expression at the end.
An array of integers should be declared as
A class which contains the abstract keyword in its declaration is known as an
Please refer to figure 1 to answer the question below: In figure 1 if(x==5) is
The first line of the code should have either a yes or no value.
Determine the output. String val_1 = “25”; String val_2 = “80”;
What does ‘new’ in int[ ] myArray = new int[n] do?
is also known as a parent class.
Determine the output. String val_1 = “foobar”; String val_2 = “”;
Polymorphic objects can pass (answer) Is-a test.
True or False: Traditional comments start with /** (forward slash and two asterisks) and ends with */ (asterisk and forward slash).
True or False: Netbeans is one of the IDEs or Integrated Development Environment to run Java programs.
For-loops can check the test expression at the end.
Polymorphism is the ability of a Java object to take
Constructors can have
When the program runs, and assuming there are no errors, its first line will be begin printing.
Which of these is a proper decrement?
All are methods of the array class except
The error in Figure 2 is
A constructor (answer) contain an explicit return type.
Abstracted methods need (answer) for implementations.
Line 14 will yield an error. It will be corrected if you place */ after the method.
The name of a constructor must be (answer) as your class.
The limit of dimensions an array can have without errors is
This type of declaration is discouraged.
The following figure shows the Netbeans Integrated Development Environment.
The equivalent of clauses in coding is?
Int num = 1; for(num=num;num<=10;num++) is an acceptable code snippet.
Loop that has a pre-determined number of iterations
An int can be used even if it is declared outside a for-loop.
Overload methods must be the same name as the class.
What the break statement in this example does is ________.
The random( ) method sorts the array randomly.
The last part in a for loop setup can be an ________.
The “1” in arrayName[1] is called an ________.
The continue; statement ends all the iterations of a loop.
Which is not a proper increment?
Infinite for-loops can be declared as for( ){ }.
If-if is more logical than else-if.
The else statement can be removed if not needed.
Expressions, Statements and Blocks are like composing sentences and paragraphs.
You can declare a new method in the subclass which is not declared in the superclass.
The return value of the equals( ) method is ________.
The Arrays.sort( ) method sorts an array into _________ order.
This type of declaration is discouraged: “int myArray[]”
An if-else-if-else statement is a block.
If the increment num=num+2 is changed to num++, the final value of num will be ________.
The term of each pass through a loop makes is called?
Loops must always have a continue or break statement.
1+2+3/4*5 is an unambiguous expression.
Conditional statements can contain more conditional statements.
int num = 1; if(num==1 && num<=1){body;} The conditional statement will _______.
byte[][][] myArray; is an example of ________.
An array _______ hold objects.
A reference variable can be reassigned to other objects provided that it is not declared ________.
The test expression of conditional statement cannot contain _______
Each pass through of a loop is called a cycle.
If the increment “num = num + 2” is changed to “num = num + 1” the final output will be _______.
Ifs and else-ifs test expressions return true or false.
_______ classes increase the encapsulation of you methods and data.
Constructed methods are initialized with 0 or null depending on the data type.
The else statement catches whatever argument the if and else-if didn’t.
An iteration of a loop is equivalent to one pass through.
If we change the initial value of num in line 6 to “num = 0”, the println output will be _______
The else-if statement can be used alone.
Abstract methods need sub-classes to contain their implementations.
The method arraycopy( ) does what?
An array can be infinitely long.
A loop can contain no expressions or statements inside.
Conditional statements are the same as declaration statements.
You cannot use inherited methods directly in a child class.
The equals( ) method compares 2 arrays.
Method invocations are statements.
To implement encapsulation, you have to declare class variables with the private modifier.
Inner class methods can be called by constructing the inner class.
Encapsulated data are hidden from other classes.
Refer to the code snippet below. Identify what part of a method is shown in each number (the underlined one). GIVEN: public int ____getArea__
Fill in the blanks with the correct answer. [String concatenation]
Read each statement carefully and decide whether it’s TRUE or FALSE. The filename of the Java file above is computesum.java.
Refer to the code snippet below. Identify what part of a method is shown in each number (the underlined one). GIVEN: int getArea
Fill in the blank: [String manipulation]
Procedural programming will be tricky for applications.
Strings can directly concatenated to an int.
True or False: The value of “val_3” is 3.
Fill in the blank: [String concatenation]
Refer to the code snippet below. Determine whether the given is a local variable, instance variable, access modifier or a class name. GIVEN: private class EmployeeRecord
True or False: The assigned values of “val_1” & “val_2” are integers.
Fill in the blank: [Arithmetic operation]
True or False: A method could be declared without any parameters.
Fill in the blank: [String manipulation]
Refer to the block of codes below. Read each statement carefully and decide whether it’s TRUE or FALSE. There are no errors in line 11.
Determine the output. [Code with error]
True or False: Non-procedural programming focuses on how a task is done rather than on what task should be done.
Refer to the code snippet below. Determine whether the given is a local variable, instance variable, access modifier or a class name. GIVEN: private class ____EmployeeRecord__
Determine the output. [String concatenation]
True or False: If you are running a program through CLI, the class name and the file name should be different.
Fill in the blank: [String length]
The “indexOf( )” method returns the first instance of the specified character.
Please refer to figure 1 to answer the question below: If we change the initial value of num in line 6 to “num = 0”, the println output will be
Strings can readily accept int values.
True or False: Keywords are Java reserved words which are used as identifier for interface, constants and constructs.
Refer to the code snippet below. Determine whether the given is a local variable, instance variable, access modifier or a class name. GIVEN: ____int noOfEmployee__
True or False: After compiling a Java program through the CLI, run it using the java and press Enter.
Refer to the program below. Read each statement carefully and write the output for each line specified. Line 22 will display on the screen.
Frequently Asked Questions
What is the purpose of the Java Development Kit (JDK)?
The JDK is a software development environment used for developing Java applications and applets. It includes the Java compiler (javac), the Java Runtime Environment (JRE), and other tools needed to compile and run Java programs.
What are the main features of object-oriented programming in Java?
Java supports four main features of object-oriented programming: encapsulation (hiding data within a class), inheritance (allowing classes to inherit properties from other classes), polymorphism (allowing objects to take multiple forms), and abstraction (hiding complex implementation details).
What is the difference between procedural and object-oriented programming?
Procedural programming focuses on procedures or functions to complete tasks in a step-by-step manner, while object-oriented programming organizes code into objects that encapsulate data and behavior, promoting modularity and reusability.
Why is Netbeans IDE commonly used for Java programming?
Netbeans is a popular Integrated Development Environment (IDE) for Java because it provides a user-friendly interface, code debugging tools, code completion, and support for multiple programming languages, making it easier to write, test, and deploy Java applications.
What is the significance of arrays in Java?
Arrays in Java are used to store multiple values of the same data type in a single variable. They are objects that allow efficient data management and manipulation, supporting operations like sorting, searching, and iteration.