What is the difference between a class and an object?
A class is a blueprint for creating objects; an object is a particular instance created from that class.
Study Java Class Design Essentials with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What is the difference between a class and an object?
A class is a blueprint for creating objects; an object is a particular instance created from that class.
How does an instance variable differ from a local variable?
An instance variable belongs to an object and persists with it; a local variable exists only inside the method or constructor where it is declared.
What default values does Java assign to uninitialized instance variables?
Uninitialized numeric instance variables default to 0 or 0.0, booleans to false, and reference types such as String to null.
What rules identify a Java constructor?
A constructor has the class’s name, no return type, runs when new creates an object, and may receive parameters.
What makes two constructors overloaded?
Constructor overloading means defining multiple constructors in one class with different parameter lists, varying in number or type.
When does Java stop supplying an automatic no-argument constructor?
If a class declares any constructor, Java does not automatically provide a no-argument constructor. Write one explicitly if it is needed.
What does this(...) do inside a constructor?
The call to this(...) invokes another constructor in the same class and must be the first statement in the calling constructor.
How do accessor and mutator methods differ?
An accessor, or getter, returns information without changing state. A mutator, or setter, changes the object’s state, potentially after validation.
What is encapsulation in class design?
Encapsulation combines data with its operations while restricting direct access, commonly using private fields and public methods that validate changes.
What does this refer to in an instance method?
In an instance method or constructor, this refers to the current object—the object whose code is executing.
Why write this.name = name in a constructor?
In this.name = name, this.name is the instance variable and name is the parameter. The qualification prevents the parameter from being assigned to itself.
How do static and instance variables differ?
A static variable has one shared copy for the class, whereas an instance variable has a separate copy in every object.
A progressive guide to how computing reshapes culture, economic life, public institutions, and individual opportunities, with frameworks for evaluating digital equity, bias, cybersecurity, encryption, and collective participation.
A medium-difficulty assessment of programming fundamentals, algorithmic problem solving, control flow, data structures, testing, debugging, complexity, and decidability. Questions progress from foundational understanding to applied reasoning.
A 14-question quiz on the social, economic, privacy, informational, health, and environmental risks of computing innovations, including strategies for responsible design and oversight.
A practical guide to recognizing cybersecurity threats, protecting accounts and devices, and responding safely when information or systems may be compromised.
A guided introduction to how encryption, authentication, hashing, secure protocols, and key management establish confidentiality, integrity, privacy, and trust while creating practical and legal trade-offs.
A focused review of propositional logic, quantifiers, sets, relations, functions, and foundational proof methods in discrete mathematics for computer science.
A practical guide to evaluating computing innovations by examining their benefits, risks, equity, security, participation, and long-term effects on people and communities.
A medium-difficulty quiz on integrating problem definition, representation, algorithms, complexity analysis, testing, correctness, ethical evaluation, and documentation in a computer science capstone.
A progressive guide to designing, operating, and testing systems that continue useful service despite component faults, overload, data loss, and recovery challenges.
A medium-difficulty quiz on how independently operated networks, protocols, addresses, naming systems, transport services, and routing mechanisms work together to form the Internet.
A progressive guide to how packet-switched networks encapsulate data, move it across links, and manage delay, throughput, queues, and congestion.
A structured guide to designing parallel and distributed systems through decomposition, communication, coordination, state management, scalability, and fault tolerance.