












Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!













Reference Types - ANSWER>>Refers to an object, doesn't hold the value of the object they refer to, and stores the memory address where the object is located. Can be assigned null. Object - ANSWER>>Instance of a class Primitive Types - ANSWER>>Boolean, int, byte, double, float, long, don't have methods declared to them. Literal - ANSWER>>Fixed value that doesn't need further calculations in order to be assigned to a variable Local Variables - ANSWER>>Defined within a method, must be initialized before use. In scope from declarations to end of block System.gc() - ANSWER>>Tells java system now may be a good time for Java to kick a garbage collection run
Object not reachable when: - ANSWER>>No longer has reference pointing to it & All references to the object have gone out of scope. Finalize() - ANSWER>>Only run when object eligible for garbage collection, call could run zero or one time Abstraction in 3 ways - ANSWER>>Hiding details of process from a requestor, defining contract for client & service provider, & defying a contract for all providers before servicing to it's clients Two ways of Abstracting Data - ANSWER>>Through Interface & Abstraction Classes Abstract Class - ANSWER>>1) Class that cannot be instantiated
Can import single class/interface. Use asterisk to import all public members Compile Failures- Package Statement - ANSWER>>Package statement at end of class definition Package statement within class definition Multiple package statements for class Compile Failures- Import Statement - ANSWER>>Import Statement appears before package statement. Class Declaration Components - ANSWER>>Access Modifiers Non-access modifiers Class keyword Name of class extends name of base class implements name of implemented interfaces {} Class body within {} (Fields, methods, constructors)
Class - ANSWER>>Design to specify properties and behaviors of an object. Design from which an object can be created Class Variables - ANSWER>>Implements properties of an object, In scope from declaration until program ends Class Methods - ANSWER>>Implement behavior of an object, includes optional argument list Class state - ANSWER>>Defined using attributes or instance variables Class Definition Components - ANSWER>>Attributes or instance variables Methods optional arguments Constructors Comments Instance Variables - ANSWER>>In scope from declaration until object garbage is collected, used to store object state Defined in the class but are outside of the class methods. Each object has it's own copy that isn't shared Instance Attributes - ANSWER>>used to store object states Defined in the class but are outside of the class methods.
Public interface - ANSWER>>Name must match source file name One public interface/class per source file Compiler Errors- Public interface/Class - ANSWER>>Only one public interface/class per source file Java application - ANSWER>>Multiple source code files, one containing executable class Executable Class - ANSWER>>JVM starts execution at main method Main Method - ANSWER>>Method that much accept an argument of a string array or a variable argument of type String public static /status void main Subpackages - ANSWER>>Used for GUIs, database access & networking Import static - ANSWER>>To import a static class member or all static members Accessing all public static members: import static Class definition - ANSWER>>Can only use public or default access modifiers for top class
Top level class - ANSWER>>Defined using only default or Public Access modifiers, isn't defined within another class, not a nested class Access Modifier - ANSWER>>Controls accessibility of class/interface and it's members(methods/variables) Can apply to class, interface and their members(instance and class variables and methods) Cannot apply to local variables Cannot apply to method parameters 4 Types of Access Modifiers - ANSWER>>Public, protected, private, default Default Access - ANSWER>>Access when a class, interface, method, or variable is defined without an explicit access modifier Public Access - ANSWER>>Least restrictive, access across all packages including derived and unrelated classes Protected Access - ANSWER>>Accessible a class/interface in the same package or derived classes in separate packages Derived class can inherit and access protected members of its base class regardless of the package in which its defined, BUT a derived class in a separate package can't access protected members of its base class using reference variables
volatile [variable] - ANSWER>>1) Non-access modifier
Final variable - ANSWER>>Can be assigned a value only once and can't reassign a new value, can call a method on it Final method - ANSWER>>Cannot be overridden by a derived class Override method - ANSWER>>Has same signature as base class method Static modifier - ANSWER>>Non access and can use with classes, variables, methods, and interfaces Constants - ANSWER>>Use final and static to define variables who's values cannot change Define them as static allows them to be used across classes and objects Static variables and methods - ANSWER>>1) If non-private, they are inherited by derived classes.
char c3 = (char)- 122
Relational operators - ANSWER>>Compare primitives < <= > >= == != Used to determine whether a primitive value is equal to, less than or greater than another value Result is always true or false Cannot compare incomparable values Logical operators - ANSWER>>Apply NOT, AND, OR logic to primitives I, &&, II Return a boolean value Assignment operator = - ANSWER>>= , used to initialize variables with values, used to reassign new values to variables Assignment operator += - ANSWER>>+=, first add then assign a +=b means a = a + b Assignment operator - = - ANSWER>>-=, first subtract then assign a - = b means a = a - b Assignment operator *= - ANSWER>>multiply then assign a = b means a = ab
Assignment operator /= - ANSWER>>divide then assign a /=b means a = a/b Modulus operator - ANSWER>>% remainder in division 10 % 6 = 4 Unary increment operator - ANSWER>>++ increments by 1 ++10 = 11 Unary decrement operator - ANSWER>>-- decrements by 1 --10 = 9 Logical AND && - ANSWER>>evaluates to true if all operands are true Logical OR II - ANSWER>>evaluates to true if any or all of the operands is true Logical negotiation! - ANSWER>>negates the boolean value and evaluates to true or false
Advantages of Exceptions - ANSWER>>Improving program structure because error handling code separated from normal program function, programmer can choose where to handle he exceptions & allows for new exceptions that are tailored to the particular program An abstract class can be implemented by an interface T/F - ANSWER>>T An abstract class can be extended by a concrete class T/F - ANSWER>>T What is the scope of a class variable or static field? - ANSWER>>Available within all objects of the current class. What is included in a default constructor of a subclass? - ANSWER>>Invocation of the superclass. How many classes can be derived from a parent class? - ANSWER>>Infinite number How many times will statements in a block execute while(true)? - ANSWER>>An Infinite number Interfaces can extend classes T/F? - ANSWER>>False
Interfaces can extend other interfaces T/F? - ANSWER>>True Can you extend more than one class in java? - ANSWER>>No