OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide
eBook - ePub

OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide

Exam 1Z0-808

Jeanne Boyarsky, Scott Selikoff

Share book
  1. English
  2. ePUB (mobile friendly)
  3. Available on iOS & Android
eBook - ePub

OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide

Exam 1Z0-808

Jeanne Boyarsky, Scott Selikoff

Book details
Book preview
Table of contents
Citations

About This Book

Full coverage of functional programming and all OCA Java Programmer exam objectives

OCA, Oracle Certified Associate Java SE 8 Programmer I Study Guide, Exam 1Z0-808 is a comprehensive study guide for those taking the Oracle Certified Associate Java SE 8 Programmer I exam (1Z0-808). With complete coverage of 100% of the exam objectives, this book provides everything you need to know to confidently take the exam. The release of Java 8 brought the language's biggest changes to date, and for the first time, candidates are required to learn functional programming to pass the exam. This study guide has you covered, with thorough functional programming explanation and information on all key topic areas Java programmers need to know. You'll cover Java inside and out, and learn how to apply it efficiently and effectively to create solutions applicable to real-world scenarios.

  • Work confidently with operators, conditionals, and loops
  • Understand object-oriented design principles and patterns
  • Master functional programming fundamentals

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide an online PDF/ePUB?
Yes, you can access OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide by Jeanne Boyarsky, Scott Selikoff in PDF and/or ePUB format, as well as other popular books in Informatique & Programmation en Java. We have over one million books available in our catalogue for you to explore.

Information

Publisher
Sybex
Year
2014
ISBN
9781118957424

Chapter 1
Java Building Blocks

OCA exam objectives covered in this chapter:

  • correct
    Java Basics
    • Define the scope of variables
    • Define the structure of a Java class
    • Create executable Java applications with a main method; run a Java program from the command line; including console output
    • Import other Java packages to make them accessible in your code
    • Compare and contrast the features and components of Java such as platform independence, object orientation, encapsulation, etc.
  • correct
    Working with Java Data Types
    • Declare and initialize variables (including casting or primitive types)
    • Differentiate between object reference variables and primitive variables
    • Know how to read or write to object fields
    • Explain an Object's Lifecycle (creation, “dereference by reassignment” and garbage collection
Welcome to the beginning of your journey to become certified on Java. We assume this isn't the first Java programming book you've read. Although we do talk about the basics, we do so only because we want to make sure you have all the terminology and detail you'll need for the OCA exam. If you've never written a Java program before, we recommend you pick up an introductory book on any version of Java—something like Head First Java, 2nd Edition (O'Reilly Media, 2005); Java for Dummies (For Dummies, 2014), or Thinking in Java, 4th Edition (Prentice Hall, 2006). (It's okay if the book covers an older version of Java—even Java 1.3 is fine.) Then come back to this certification study guide.
This chapter covers the fundamentals of Java. You'll see how to define and run a Java class, and learn about packages, variables, and the object life cycle.

Understanding the Java Class Structure

In Java programs, classes are the basic building blocks. When defining a class, you describe all the parts and characteristics of one of those building blocks. To use most classes, you have to create objects. An object is a runtime instance of a class in memory. All the various objects of all the different classes represent the state of your program.
In the following sections, we'll look at fields, methods, and comments. We'll also explore the relationship between classes and files.

Fields and Methods

Java classes have two primary elements: methods, often called functions or procedures in other languages, and fields, more generally known as variables. Together these are called the members of the class. Variables hold the state of the program, and methods operate on that state. If the change is important to remember, a variable stores that change. That's all classes really do. It's the programmer who creates and arranges these elements in such a way that the resulting code is useful and, ideally, easy for other programmers to understand.
Other building blocks include interfaces, which you'll learn about in Chapter 5, “Class Design,” and enums, which you'll learn about when you start studying for the OCP exam.
The simplest Java class you can write looks like this:
1: public class Animal { 2: }
Java calls a word with special meaning a keyword. The public keyword on line 1 means the class can be used by other classes. The class keyword indicates you're defining a class. Animal gives the name of the class. Granted, this isn't a very interesting class, so add your first field:
1: public class Animal { 2: String name; 3: }
image

The line numbers aren't part of the program; they're just there to make the code easier to talk about.
On line 2, we define a variable named name. We also define the type of that variable to be a String. A String is a value that we can put text into, such as "this is a string ". String is also a class supplied with Java. Next you can add methods:
1: public class Animal { 2: String name; 3: public String getName() { 4: return name; 5: } 6: public void setName(String newName) { 7: name = newName; 8: } 9: }
On lines 3–5, you've defined your first method. A method is an operation that can be called. Again, public is used to signify that this method may be called from other classes. Next comes the return type—in this case, t...

Table of contents