Oracle Certified Java Associate (OCA) Exam Preparation

Friends! I recently appeared for OCA exam and scored 95%. Here i am sharing few techniques and exam question patterns which must be helping you while appearing for OCA test. This exam guarantee to ask question on the below topics or we can say statements. Exam code: 1Z0-808 1. Must practice the differences between str1 == str2 and str1.equals(str2). Example-1.1:

Java

class Test < public static void main(String[] args) String s = new String("hello"); String s2 = "hello"; System.out.println("=="); if (s.equals(s2)) < System.out.println("equals"); Output:
equals

Reason: Because String class equals method compare objects, but == operator only compares references. If both the references are pointing to the same object then only == operator returns true. Example-1.2:

Java

class Test < public static void main(String[] args) String s = new String("hello"); String s2 = s; System.out.println("=="); if (s.equals(s2)) < System.out.println("equals"); Output:
== equals

Reason: Because both the references are pointing to the same object so “==” printed and If both the reference are pointing to the same object so by default they the equal so “equals” printed. 2. Study ternary operator and its compile time errors. Example-2.1:

Java

class Test < public static void main(String[] args) int marks = 90 ; String result = marks > 35 ? "Pass" : "Fail"; System.out.println(result); Output:
Pass

Example-2.2:

Java

class Test < public static void main(String[] args) int marks = 90 ; String result = marks > 60 ? "Pass with 1st div." : marks < 50 ? "Pass with 2nd div." : marks < 40 ? "Pass with 3rd div."; System.out.println(result);

Java

class Test < public static void main(String[] args) String ta = "A "; ta = ta.concat("B "); String tb = "C "; ta = ta.concat(tb); ta.replace( 'C' , 'D' ); ta = ta.concat(tb); System.out.println(ta); Output:
A B C C

4. Lambda expression and its simplified forms. Java Lambda Expression Syntax: (argument-list) -> 4.1 Lambda Expression Example: No Parameter

Java

// This a java method void printHello() System.out.println("Hello World "); // As lambda the above method can be written as below // <> is optional for single line statement () -> System.out.println("Hello World ");

4.2 Lambda Expression Example: Single Parameter

Java

// This a java method void sayHello(String name) System.out.println("Hello " + name); (name) -> System.out.println("Hello " + name); // () optional for single input parameter. name -> System.out.println("Hello " + name);

4.3 Lambda Expression Example:Multiple Parameter

Java

// This a java method int add( int num1, int num2) return num1 + num2; ( int num1, int num2) -> < return num1 + num2; >; ( int num1, int num2) -> num1 + num2; // () mandatory for more than one input parameter. (num1, num2) -> num1 + num2;

5. Study the difference between &(Bitwise AND) and &&(Logical AND) Operator. Example-5.1:

Java

class Test < public static void main(String[] args) System.out.println("Output of && operator: " + "a = " + a + " b = " + b); System.out.println("-------------"); System.out.println("Output of & operator: " + "a = " + a + " b = " + b); Output:
Output of && operator: a = 11 b = 20 ------------- Output of & operator: a = 11 b = 19

Reason: Because ‘&&’ operator doesn’t check second operand if value for the first operand is ‘false’. But ‘&’ must check both the operands. Note: These concept definitely covers 10 – 12 questions in OCA Exam.

Like Article -->

Please Login to comment.

Similar Reads

How to Become Oracle Certified Java Programmer(OCJP)?

Java developers are one of the most elite developing sectors in the IT industry and their demand has never been dull in these years. For the past three decades, it has dominated the entire industry across the world. Call it getting decent pay, a better opportunity, and elevation in career, Java has always been an electrifying technology for everyon

4 min read Oracle Launches Java 22 and Confirms JavaOne 2025 Return

Java, received a significant upgrade on March 19, 2024, with the official launch of Java 22 by Oracle. This latest iteration focuses on empowering developers with enhanced performance, improved security, and a more streamlined development process. Additionally, Oracle announced the much-anticipated return of JavaOne, the premier Java developer conf

7 min read Oracle Interview Experience | Server Technology Role Full Time (On-Campus Sept 2020)

Oracle came to our campus in Sept 2020, for a server technology profile. All rounds were audio and video proctored. The entire interview process was on zoom meetings. It was a very smooth virtual experience. There were counter rooms inside zoom meetings for post and pre-interview sessions. Round 1 – It was an online test consisting of four sections

3 min read Migration to Open JDK from Oracle JDK

Let us first discuss the need for migration. It is as follows as in the year 2018, Oracle announced that after January 2019, businesses will need to purchase a commercial license (i.e., from Oracle) in order to receive software updates. Keep Oracle Java and upgrade to supported patch level and pay the subscription costs. To give you an idea of the

5 min read Oracle Interview Experience | 3.5 Years Experienced

Technical Round 1: Difference b/w C++ and java. How Java bytecode is platform independent?https://www.geeksforgeeks.org/design-a-stack-that-supports-getmin-in-o1-time-and-o1-extra-space/https://www.geeksforgeeks.org/rotate-matrix-90-degree-without-using-extra-space-set-2/ Technical Round 2: https://leetcode.com/problems/course-schedule-ii/

1 min read Oracle Interview Experience | (Application Developer for 2.5 Years Experienced)

I had applied for the role Application Developer (Java development) in Oracle's job portal. I was contracted via mail a month later. I got interview invite for a weekend drive. The job location was at Hyderabad, but the interview was conducted in Chennai. There were 3 problem solving rounds, 1 design round and 1 video conference manager round. In a

4 min read Difference Between java.sql.Time, java.sql.Timestamp and java.sql.Date in Java

Across the software projects, we are using java.sql.Time, java.sql.Timestamp and java.sql.Date in many instances. Whenever the java application interacts with the database, we should use these instead of java.util.Date. The reason is JDBC i.e. java database connectivity uses these to identify SQL Date and Timestamp. Here let us see the differences

7 min read JUnit Testcases Preparation For a Maven Project

The quality of a software project is the desired aspect always. Programmers write code and they will do unit testing, block level testing, and sometimes integration testing too. But they will provide a few examples alone for the use cases. For example, if they are finding a number is prime or not, maybe they will provide some 2 to 3 different sets

4 min read Java AWT vs Java Swing vs Java FX

Java's UI frameworks include Java AWT, Java Swing, and JavaFX. This plays a very important role in creating the user experience of Java applications. These frameworks provide a range of tools and components for creating graphical user interfaces (GUIs) that are not only functional but also visually appealing. As a Java developer, selecting the righ

11 min read Java.io.ObjectInputStream Class in Java | Set 2

Java.io.ObjectInputStream Class in Java | Set 1 Note : Java codes mentioned in this article won't run on Online IDE as the file used in the code doesn't exists online. So, to verify the working of the codes, you can copy them to your System and can run it over there. More Methods of ObjectInputStream Class : defaultReadObject() : java.io.ObjectInpu

6 min read Java.lang.Class class in Java | Set 1

Java provides a class with name Class in java.lang package. Instances of the class Class represent classes and interfaces in a running Java application. The primitive Java types (boolean, byte, char, short, int, long, float, and double), and the keyword void are also represented as Class objects. It has no public constructor. Class objects are cons

15+ min read Java | Java Packages | Question 3

Predict the output of following Java program // Note static keyword after import. import static java.lang.System.*; class StaticImportDemo < public static void main(String args[]) < out.println("GeeksforGeeks"); >> (A) Compiler Error (B) Runtime Error (C) GeeksforGeeks (D) None of the above Answer: (C) Explanation: Please refer https://w

1 min read Java.lang.StrictMath class in Java | Set 2

Java.lang.StrictMath Class in Java | Set 1More methods of java.lang.StrictMath class 13. exp() : java.lang.StrictMath.exp(double arg) method returns the Euler’s number raised to the power of double argument. Important cases: Result is NaN, if argument is NaN.Result is +ve infinity, if the argument is +ve infinity.Result is +ve zero, if argument is

6 min read java.lang.instrument.ClassDefinition Class in Java

This class is used to bind together the supplied class and class file bytes in a single ClassDefinition object. These class provide methods to extract information about the type of class and class file bytes of an object. This class is a subclass of java.lang.Object class. Class declaration: public final class ClassDefinition extends ObjectConstruc

2 min read Java.util.TreeMap.pollFirstEntry() and pollLastEntry() in Java

Java.util.TreeMap also contains functions that support retrieval and deletion at both, high and low end of values and hence give a lot of flexibility in applicability and daily use. This function is poll() and has 2 variants discussed in this article. 1. pollFirstEntry() : It removes and retrieves a key-value pair with the least key value in the ma

4 min read Java.util.TreeMap.floorEntry() and floorKey() in Java

Finding greatest number less than given value is used in many a places and having that feature in a map based container is always a plus. Java.util.TreeMap also offers this functionality using floor() function. There are 2 variants, both are discussed below. 1. floorEntry() : It returns a key-value mapping associated with the greatest key less than

3 min read java.lang.Math.atan2() in Java

atan2() is an inbuilt method in Java that is used to return the theta component from the polar coordinate. The atan2() method returns a numeric value between -[Tex]\pi [/Tex]and [Tex]\pi [/Tex]representing the angle [Tex]\theta [/Tex]of a (x, y) point and the positive x-axis. It is the counterclockwise angle, measured in radian, between the positiv

1 min read java.net.URLConnection Class in Java

URLConnection Class in Java is an abstract class that represents a connection of a resource as specified by the corresponding URL. It is imported by the java.net package. The URLConnection class is utilized for serving two different yet related purposes, Firstly it provides control on interaction with a server(especially an HTTP server) than URL cl

5 min read Java 8 | ArrayDeque removeIf() method in Java with Examples

The removeIf() method of ArrayDeque is used to remove all those elements from ArrayDeque which satisfies a given predicate filter condition passed as a parameter to the method. This method returns true if some element are removed from the Vector. Java 8 has an important in-built functional interface which is Predicate. Predicate, or a condition che

3 min read Java.util.GregorianCalendar Class in Java

Prerequisites : java.util.Locale, java.util.TimeZone, Calendar.get()GregorianCalendar is a concrete subclass(one which has implementation of all of its inherited members either from interface or abstract class) of a Calendar that implements the most widely used Gregorian Calendar with which we are familiar. java.util.GregorianCalendar vs java.util.

10 min read Java lang.Long.lowestOneBit() method in Java with Examples

java.lang.Long.lowestOneBit() is a built-in method in Java which first convert the number to Binary, then it looks for first set bit present at the lowest position then it reset rest of the bits and then returns the value. In simple language, if the binary expression of a number contains a minimum of a single set bit, it returns 2^(first set bit po

3 min read Java Swing | Translucent and shaped Window in Java

Java provides different functions by which we can control the translucency of the window or the frame. To control the opacity of the frame must not be decorated. Opacity of a frame is the measure of the translucency of the frame or component. In Java, we can create shaped windows by two ways first by using the AWTUtilities which is a part of com.su

5 min read Java lang.Long.numberOfTrailingZeros() method in Java with Examples

java.lang.Long.numberOfTrailingZeros() is a built-in function in Java which returns the number of trailing zero bits to the right of the lowest order set bit. In simple terms, it returns the (position-1) where position refers to the first set bit from the right. If the number does not contain any set bit(in other words, if the number is zero), it r

3 min read Java lang.Long.numberOfLeadingZeros() method in Java with Examples

java.lang.Long.numberOfLeadingZeros() is a built-in function in Java which returns the number of leading zero bits to the left of the highest order set bit. In simple terms, it returns the (64-position) where position refers to the highest order set bit from the right. If the number does not contain any set bit(in other words, if the number is zero

3 min read Java lang.Long.highestOneBit() method in Java with Examples

java.lang.Long.highestOneBit() is a built-in method in Java which first convert the number to Binary, then it looks for the first set bit from the left, then it reset rest of the bits and then returns the value. In simple language, if the binary expression of a number contains a minimum of a single set bit, it returns 2^(last set bit position from

3 min read Java lang.Long.byteValue() method in Java with Examples

java.lang.Long.byteValue() is a built-in function in Java that returns the value of this Long as a byte. Syntax: public byte byteValue() Parameters: The function does not accept any parameter. Return : This method returns the numeric value represented by this object after conversion to byte type. Examples: Input : 12 Output : 12 Input : 1023 Output

3 min read Java lang.Long.reverse() method in Java with Examples

java.lang.Long.reverse() is a built-in function in Java which returns the value obtained by reversing the order of the bits in the two's complement binary representation of the specified long value. Syntax: public static long reverse(long num) Parameter : num - the number passed Returns : the value obtained by reversing the order of the bits in the

2 min read java.lang.reflect.Proxy Class in Java

A proxy class is present in java.lang package. A proxy class has certain methods which are used for creating dynamic proxy classes and instances, and all the classes created by those methods act as subclasses for this proxy class. Class declaration: public class Proxy extends Object implements SerializableFields: protected InvocationHandler hIt han

4 min read Java.math.BigInteger.modInverse() method in Java

Prerequisite : BigInteger Basics The modInverse() method returns modular multiplicative inverse of this, mod m. This method throws an ArithmeticException if m <= 0 or this has no multiplicative inverse mod m (i.e., gcd(this, m) != 1). Syntax: public BigInteger modInverse(BigInteger m) Parameters: m - the modulus. Return Value: This method return

2 min read Java.math.BigInteger.probablePrime() method in Java

Prerequisite : BigInteger Basics The probablePrime() method will return a Biginteger of bitLength bits which is prime. bitLength is provided as parameter to method probablePrime() and method will return a prime BigInteger of bitLength bits. The probability that a BigInteger returned by this method is composite and does not exceed 2^-100. Syntax: pu