What is a Java method?
A method is a named block of Java code that runs when it is called. It supports procedural abstraction by hiding implementation details behind a usable operation.
Study Java Methods and Program Design with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What is a Java method?
A method is a named block of Java code that runs when it is called. It supports procedural abstraction by hiding implementation details behind a usable operation.
What are the main parts of a method declaration?
A method declaration commonly includes an access modifier, return type, name, parameter list, and body.
What does void mean as a method return type?
A void method performs an action but produces no value, so its call cannot be used in an expression or assigned to a variable.
How do parameters differ from arguments?
A parameter is a variable declared in a method header; an argument is the value supplied for that parameter when the method is called.
What happens when a primitive argument is changed inside a method?
Java passes primitive arguments by value, so the method receives a copy. Changing its parameter does not change the caller’s original variable.
What can a method do with a reference-type argument?
Java passes a copy of the reference. The method can change the shared object’s contents, but assigning a new object to the parameter does not change the caller’s reference.
What does return do in a non-void method?
A return statement ends the current method and sends a value to the caller. Every possible path of a non-void method must return a compatible value.
What constitutes a Java method signature?
A method’s signature consists of its name and ordered list of parameter types. Its return type is not part of the signature.
What is method overloading?
Overloading means defining methods with the same name but different parameter lists. Java selects the applicable overload using the number and types of arguments, not the return type.
What determines the scope of parameters and local variables?
A parameter’s scope is the entire body of its method. A local variable’s scope extends from its declaration to the end of its enclosing block.
How does this resolve a field–parameter name conflict?
When a parameter has the same name as a field, the parameter takes precedence in the method. this.name refers specifically to the current object’s field.
What is the difference between a precondition and a postcondition?
A precondition must be true before a method runs; a postcondition must be true after it finishes. Together they form a contract between caller and method.
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.