Questions and Answers
Java source files end with the .class extension.
False
What type of memory is RAM?
A volatile type of memory, used only for temporary storage
What is the purpose of validating the results of the program?
Determine if the program solves the original problem
What do the methods that operate on the data allow?
Signup and view all the answers
How many bits are in a byte?
Signup and view all the answers
What does software refer to?
Signup and view all the answers
What are symbolic names made by the programmer that represent locations in the computer's RAM?
Signup and view all the answers
A(n) ____ is a software entity that contains data and procedures.
Signup and view all the answers
What was the original name for Java?
Signup and view all the answers
What is a computer program?
Signup and view all the answers
Encapsulation refers to the combining of data and code into a single object.
Signup and view all the answers
What is a special language used to write computer programs?
Signup and view all the answers
What are byte code instructions?
Signup and view all the answers
What is the data contained in an object known as?
Signup and view all the answers
The Java Virtual Machine is a program that reads Java byte code instructions and executes them as they are read.
Signup and view all the answers
What does application software refer to?
Signup and view all the answers
What is a set of programming language statements that, together, perform a specific task?
Signup and view all the answers
Because Java byte code is the same on all computers, compiled Java programs are highly portable.
Signup and view all the answers
Application software refers to programs that make the computer useful to the user.
Signup and view all the answers
____ is a cross between human language and a programming language.
Signup and view all the answers
Whereas ____ is centered on creating procedures, ___ is centered on creating objects.
Signup and view all the answers
What is syntax?
Signup and view all the answers
A characteristic of ___ is that only an object's methods are able to directly access and make the changes to the object's data.
Signup and view all the answers
One of the design tools used by programmers when creating a model of the program is
Signup and view all the answers
A runtime error is usually the result of
Signup and view all the answers
What are variables of the boolean data type useful for?
Signup and view all the answers
Variables are classified according to their?
Signup and view all the answers
Which of the following statements will correctly convert the data type if x is a float and y is a double?
Signup and view all the answers
What is a named storage location in the computer's memory?
Signup and view all the answers
If you wish to use the System.out.printf method to print a string argument, use the ___ format specifier.
Signup and view all the answers
When saving a Java source file, save it with an extension of
Signup and view all the answers
The System.out.printf method allows you to format output in a variety of ways.
Signup and view all the answers
What will be displayed when the following code is executed? final int x = 22, y = 4; y += x; System.out.println("x = " + x + " y = " + y);
Signup and view all the answers
Character literals are enclosed in ___, and string literals are enclosed in ____.
Signup and view all the answers
Which of the following is not a valid Java comment?
Signup and view all the answers
The simplest way you can use the System.out.printf method is
Signup and view all the answers
Identifiers can contain spaces.
Signup and view all the answers
What will be the value of z as a result of executing the following code? int x=5, y=28; float z; z=(float)(y/x);
Signup and view all the answers
Which of the following statements is invalid?
Signup and view all the answers
Named constants are initialized with a value and that value cannot change during the execution of the program.
Signup and view all the answers
The primitive data types only allow a(n) ___ to hold a single value.
Signup and view all the answers
What output will be displayed as a result of executing the following code? int x = 5, y = 20; x+= 32; y/= 4; System.out.println("x=" + x + ", y=" + y);
Signup and view all the answers
What would be displayed as a result of the following code? int x = 578; System.out.print("There are " + x + 5 + "\n" + "hens in the hen house.");
Signup and view all the answers
What will be the value of z after the following statements have been executed? int x=4, y=33; double z; z=(double)(y/x);
Signup and view all the answers
What is the result of the following expression?
Signup and view all the answers
When you call one of the Scanner class's methods to read a primitive value, an annoying and hard-to-find problem can occur.
Signup and view all the answers
In the following Java statement what value is stored in the variable name? String name="John Doe";
Signup and view all the answers
A Java program must have at least one
Signup and view all the answers
Both character literals and string literals can be assigned to a char variable.
Signup and view all the answers
This is a value that is written into the code of a program.
Signup and view all the answers
What is the following statement an example of? import java.util.Scanner;
Signup and view all the answers
Both the things a class is responsible for knowing and the things a class is responsible for doing?
Signup and view all the answers
When an object is created, the attributes associated with the object are called?
Signup and view all the answers
To indicate the data type of a variable in a UML diagram, you specify?
Signup and view all the answers
Data hiding, which means that critical data stored inside the object is protected from code outside the object, is accomplished in Java by?
Signup and view all the answers
Class objects normally have ________ that perform useful operations on their data, but primitive variables do not.
Signup and view all the answers
The scope of a local variable is?
Signup and view all the answers
What is the following statement an example of? import java.util.*;
Signup and view all the answers
When an argument is passed by value,?
Signup and view all the answers
UML diagrams do not contain object names.
Signup and view all the answers
A method may have zero or more parameter variables.
Signup and view all the answers
In UML diagrams, what symbol indicates that a member is public?
Signup and view all the answers
Another term for an object of a class is a(n)?
Signup and view all the answers
What does the keyword new do?
Signup and view all the answers
One or more objects may be created from a(n)?
Signup and view all the answers
In the blueprint/house analogy, think of a class as a blueprint that describes a house and ________ as instances of the house built from the blueprint.
Signup and view all the answers
What is a group of related classes called?
Signup and view all the answers
Which of the following is not involved in finding the classes when developing an object-oriented application?
Signup and view all the answers
You should not define a class field that is dependent upon the values of other class fields in order to?
Signup and view all the answers
If you do not provide initialization values for a class's numeric fields, they will be automatically initialized with 0.
Signup and view all the answers
It is common practice in object-oriented programming to make all of a class's?
Signup and view all the answers
After the header, the body of the method appears inside a set of?
Signup and view all the answers
A UML diagram uses the ________ symbol to indicate that a member is private.
Signup and view all the answers
Methods that operate on an object's fields are called?
Signup and view all the answers
For the following code, which statement is not true? public class Sphere { private double radius; public double x; private double y; private double z; }
Signup and view all the answers
What is import scanner?
Signup and view all the answers
What is the declaration for scanner?
Signup and view all the answers
How do you close the scanner?
Signup and view all the answers
Study Notes
Java Basics
- Java source files utilize the .java extension; .class is for bytecode.
- RAM (Random Access Memory) is a volatile memory used for temporary data storage.
- Validating program results ensures that it effectively solves the intended problem.
Object-Oriented Programming
- Objects encapsulate data and methods, hiding internal data while providing access through defined procedures.
- Variables serve as symbolic names representing locations in a computer's memory.
- Encapsulation combines data and functionality within a single unit, ensuring data security.
Programming Fundamentals
- A computer program is a structured set of instructions that solve problems or perform tasks.
- Software is a term used to describe programs executed by a computer.
- Java bytecode is platform-independent, leading to high portability across different systems.
Data Types and Variables
- Variables can hold data classified by their data types, including primitive data types that store single values.
- Boolean variables evaluate conditions as true or false, essential for control flow in programming.
Java Syntax and Identifiers
- Syntax comprises specific rules programming code must adhere to; identifiers cannot contain spaces.
- Named constants in Java are immutable once initialized, providing stability in code.
Exception Handling
- A runtime error often results from logical errors in code execution.
- Understanding how errors manifest helps in debugging Java applications effectively.
Program Structures
- The UML (Unified Modeling Language) diagram indicates relationships between classes, identifying attributes and methods.
- A class definition is fundamental for creating objects, establishing a blueprint for data structure and functionality.
Input and Output Management
- The System.out.printf method formats output, and the simplest usage requires only a format string.
- User input handling often involves the Scanner class, a common approach for reading data in Java applications.
Scoping and Accessibility
- Local variables' scope is restricted to the method in which they are defined.
- Data hiding ensures object fields are protected from outside interference, promoting encapsulation principles.
Class Relationships
- A class may produce multiple object instances, referred to as instances.
- Packages group related classes, enhancing organization within the programming structure.
Best Practices in Programming
- Following conventions, such as keeping fields private, enhances data security.
- Avoid defining class fields based on others to maintain clean, understandable code.
Fundamental Operations
- An implicit conversion of data types can be performed while assigning values.
- The keyword
new
is crucial for object instantiation in memory.
Summary of Common Features
- Comments serve as documentation within code but cannot be enclosed improperly.
- Understanding the context of variable manipulations is essential for predictable program behavior.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
Test your knowledge with this quiz covering Chapters 1-3 of Java programming. The questions focus on basic concepts such as file extensions, memory types, and program validation. Perfect for beginners looking to strengthen their understanding of Java fundamentals.