Java 8 Questions for Oracle Certified Associate Java SE 8 Programmer 1 study set with 10, Exams of Computer Science

Java 8 Questions for Oracle Certified Associate Java SE 8 Programmer 1 study set with 100% verified solutions-personalized success 2025-2026

Typology: Exams

2024/2025

Available from 04/18/2025

studycamp
studycamp 🇺🇸

3.8

(37)

20K documents

1 / 31

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Java 8 Questions for Oracle Certified Associate Java SE
8 Programmer 1
study set with 100% verified solutions-personalized
success 2025-2026
113Q&A
What year was the Java programming created
1995
What does OCA stand for
Oracle Certified Associate
What are the 2 tests for Java developers provided by Oracle
OCA and OCP
The full declaration of a method is called the method ____
signature
True or False - can you add a multiline comment within a multiline
comment?
false
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f

Partial preview of the text

Download Java 8 Questions for Oracle Certified Associate Java SE 8 Programmer 1 study set with 10 and more Exams Computer Science in PDF only on Docsity!

Java 8 Questions for Oracle Certified Associate Java SE

8 Programmer 1

study set with 100% verified solutions-personalized

success 2025-

113Q&A

What year was the Java programming created 1995 What does OCA stand for Oracle Certified Associate What are the 2 tests for Java developers provided by Oracle OCA and OCP The full declaration of a method is called the method ____ signature True or False - can you add a multiline comment within a multiline comment? false

How many public classes can be added to a single file 1 Write the syntax for the main method. public static void main(String[] args) When you compile a Java class what file type extension is output? .class What does a .class file contain bytecode True or false, what creating a public Java class in a file does the case used in the file name have to match the case used by the Java class name? true In a method declaration, the public, protected and private declarations are called what? access modifiers What is the one special package in Java that you don't need to import? java.lang

What package is the ArrayList class in? java.util. When defining a constructor for class Junk, what is the proper syntax? public Junk() { } // notice there is NO return value. What is a code block outside of a method called? instance initializer Given the class public class Junk { int eggs=0; public Junk() { eggs=1; } { eggs = 10; } } what is the value of eggs and why? Answer: 1 Reason: The value is 1 because the fields and instance initializers are run in the order they are declared and lastly the constructor is run. In the following code snippet, will this compile? public class Junk { { eggs = 6; } int eggs; } Why or why not?

Answer: Won't Compile Reason: This will not compile because the instance initializer will try to set a field that hasn't been declared yet. What are the two types of data that Java applications contain? primitive type and reference types How many primitive data types does Java have? Answer: 8 There are 8 primitive data types: boolean, byte, short, int, long, float, double and char. What are the 8 Java primitive types? boolean, byte, short, int, long, float, double and char How many bits is an int primitive data type 32 bits How many bits is a long primitive data type? 64 bits Which of these floating point data types is bigger? float or double?

What is the maximum number an int can hold Answer: 2,147,483, When declaring a literal number what type does Java assume the data is? Answer: int Reason: Java assumes the data is an int. If you want a really big number you have to add an "L" to the end to get a long. How would you define a literal binary number in Java? Answer: add the 0b prefix Reason: By adding 0b you can then add the binary values such as 0b How would you define a literal octal number in Java? Answer: add 0 prefix Reason: By adding a 0 prefix, you can define an octal number such as 017 which is equal to decimal 15. How would you define a literal hex value in Java? Answer: Add a 0x prefix

Reason: By adding a 0x prefix, you can define a hex number. For example; 0x1F is 31. In Java 7, what feature was added to make numbers easier to read? An underscore option was created. int million = 1_000_000; the underscore cannot be first, before a decimal, after a decimal or at the end, but its OK elsewhere. Is the following statement valid? int value = null; Answer: No Reason: Primitive types cannot be set to null. As a general rule, all primitives start with: a.) lowercase b.) uppercase letters Answer: a. lowercase Reason: That's just the way it is.

1.) must begin with a letter or a $ or _ 2.) subsequent characters may also be numbers. 3.) cannot use Java reserved words. When declaring a local variable, what is the default value? Local variables do not have a default value and contain garage until initialized. You cannot use a local variable in a method until it is initialized. What is wrong with the following code snippet? public void test(boolean check) { int answer1; int answer2; if (check) { answer1 = 1; answer2 = 2; } else { answer2 = 2; } System.out.println(answer1); System.out.println(answer2); } This won't compile because the local variable answer1 is never initialized.

How do you identify a class variable? It has the keyword static before it. What is the default value for an instance variable of type boolean? false What is the default value for an instance variable of type byte, short, int and long? 0 What is the default value for an instance variable of type float or double?

What is the default value for an instance variable of type char? '\u0000' (NUL) What is the default value for an object reference? null What is the scope of a class variable? in scope from the declaration of the class until the program ends. What is the scope of an instance variable? In scope from the declaration until object garage collected.

For the exam, it is good to know that this finalize() method will run 0 or one time. In the following snippet, what happens when the garbage collector run finalize()? public class Finalizer { private static List objects = new ArrayList(); protected void finalize() { objects.add(this); } } The garbage collection of this object is aborted. Later, if the object becomes eligible, the finalize() method will not be called a second time. What are the 3 styles of comments? 1.) single line comment 2.) multi-line comment 3.) JavaDoc comment What are the 6 key benefits to Java? OO, E, PI, R, S, S

1.) object oriented 2.) encapsulation through access modifiers to protect data from unintended access. 3.) platform independent 4.) robust - no memory leaks. 5.) simple - no pointers, no operator overloading 6.) secure - runs in a JVM What does the following program print? public class Test { public static void main(String[] args) { System.out.println(args[0]); } } java Test hello hello Which of the following are valid Java identifiers? a.) A$B b.) _helloWorld c.) true d.) java.lang

cause a compiler error, but it doesn't because main() is considered part of the class. Which of the following are OK? a.) short numPets = 5; b.) int numGrains = 5.6; c.) String name = "Scruffy"; d.) numPets.length(); e.) numGrains.length(); f.) name.length(); a is OK b is not because 5.6 is a float c is OK d is not because numPets is not an object e is not because numGrains is not an object f is OK because name is an object Given the following class, which of the following is true? 01: public class Snake { 02: 03: public void shed(boolean time) { 04: 05: if (time) {

08: System.out.println(result); 09: 10: } 11: } a.) if String result = "done"; is added to line 2, the code will compile b.) if String result = "done;"; is added on line 4, the code will compile c.) if String result = "done"; is added to line 6, the code will compile d.) if String result = "done"; is added to line 9, the code will compile e.) None of the above changes will make the code compile. a is OK b is OK c won't work because result will be out of scope d won't work because it is too late e is obviously not the answer Given the following package structure, which Water class will be used? <com.test.aquarium> class Water

a.) package my.directory.named.a; b.) package my.directory.named.A; c.) package named.a; d.) package named.A; e.) package a; f.) package A; g.) Does not compile d.) package named.A What is an example of a unary operator? ++ or -- What is the result: System.out.println( 10 / 3); 3 What is the result System.out.println(10 % 3) 1 In numeric promotion what happens when two values have different data types?

Java will automatically promote the one of the values to the larger of the two data types. In numeric promotion, what happens when one value is an integral value and the other is a floating-point? Java will promote the integral value to the floating values data type In numeric promotion, what happens when a byte, short or char are used? They are promoted to int before being used in the calculation In numeric promotion, what is the resulting data type It will be the same data type as the promoted operand What is the data type returned from the following expression? int x = 1; long y = 33; ? = x * y ? will be a long data type because of numeric promotion What is the data type returned from the following expression? double x = 39.21;