Methods in Java

Duration: 15 min

This video lesson is available to enrolled students.

Return to /learn/ASRB-ICAR-T3-T4-INFORMATION-TECHNOLOGY-PRELIMS-MAINS/oops-with-c-java/oops-with-java/classes-objects/asset-methods-in-java-25115 after enrolling

Inside: a video lesson and guided study material.

Module outline

  1. Prelims: General Knowledge: Physics Chemistry Biology History Geography Polity Indian Economy Static General Knowledge GK- Current Affairs Environment
  2. Prelims: General English: Vocabulary Noun Pronoun Adjectives Preposition Articles Direct and Indirect Speech Tenses Conjunction Subject Verb Agreement (Verb Noun Agreement) Modals Sentence Re-arrangements (Para Jumbles) (Narrative Sequencing) Sentence Correction (Error Correction) Sentence Completion (Fill in the blanks) Comprehension / Reading Comprehension / Unseen Passages (Critical Reasoning) (Paragraph Questions) Cloze Test (Cloze Passage) Verbal Analogy (Word Based Analogy) Sentence Construction Adverb Verb
  3. Prelims: Quantitative Aptitude: Percentage Ratio and Proportion (Ratios) HCF LCM Divisibility Rules Average Sequence and Series (Series) Number System Powers and Exponents (Surds and Indices) Algebra Profit and Loss Simple Interest and Compound Interest Time and Work Pipe and Cistern Speed Time and Distance Mixture and Alligation Mensuration and Geometry Age Problems Partnership Statistics Data Interpretation Arithmetic
  4. Prelims: General Agriculture: Agriculture in India and Tripura Natural Resource Management Fundamentals of Crop Production Horticulture Crop Improvement Crop Protection Social Science
  5. IT Mains: Operating System: Introduction to OS Process Management CPU Scheduling Process Synchronization Threads & Process Creation Deadlock Memory Management Virtual Memory Disc Scheduling File Management Distributed Systems
  6. IT Mains: Computer Networking: Introduction to CN DLL: Access Control DLL: Flow Control DLL: Error Control Data Link Layer - Ethernet Net Layer: IPv4 & Proto Net Layer: IP Addressing Net Layer:Routing Protocol Transport Layer Services TL: Congestion & UDP Application Layer Hardware Basics Network Security
  7. IT Mains: DBMS: Basics of DBMS ER Diagram Relational Model & Functional Dependencies Keys & Integrity Constraints Normalization (1NF - BCNF) Decomposition Properties & 4NF Relational Algebra SQL Relational Calculus Transaction Management Concurrency Control Database Recovery Big Data Systems Database Security & Authorization Enhanced Data Models NoSQL
  8. IT Mains: Software Engineering: Fundamentals of Software Engineering Software Requirements and Quality Assurance Software Design, Estimation and Metrics Software Testing Software Maintenance and Configuration Management
  9. IT Mains: Data Structures & Algorithms: Introduction to DS Array Stack Queue Linked List Tree Graphs Hashing Algorithm Analysis Time Complexity Analysis Sorting Algorithms
  10. IT Mains: OOPS with C++ & Java: C Fundamentals OOPS with C++ Java Fundamentals Array, String, IO & References OOPS with Java Generic & Collections Multithreading File Handling & I/O
  11. IT Mains: Python: Introduction to Python Tokens, Variables, Data Types, I/O Operators & Expressions Control Flow & Looping Collections & Strings Functions & Modules
  12. IT Mains: Website Development: Website, Browser & Services Internet Fundamentals Web Design & Development Protocols & Services Web Publishing & Hosting Server Side & Security Emerging Technologies HTML Basics HTML5 CSS JavaScript-Basics .Net Programming PHP
  13. IT Mains: Mobile App Development: Mobile Computing Multimedia
  14. IT Mains: Linux / Windows Server Admin: Unix OS Linux OS
AI summary & chapters

AI Summary

An AI-generated summary of this video lecture.

This lecture introduces Java methods, defining them as reusable blocks of code that execute only when invoked. The instructor uses a calculator-button analogy and lists benefits such as reusability, maintenance, organization, and readability. The general syntax returnType methodName(parameters) is explained, with annotations showing return type, method name, and parameters. A practical example defines a void add(int a, int b) method and calls it with c.add(10, 20), producing output 30. The lesson then contrasts predefined library methods like Math.max(10, 20) with user-defined methods like add(10, 20), using a comparison table and code panels. Finally, variable arguments (varargs) are introduced with the syntax returnType methodName(dataType... variable), demonstrated through a sum(int... numbers) method that accepts varying numbers of int arguments, with outputs such as 30 and 100 shown.

Chapters

  1. 0:00 – 2:00 00:00-02:00

    The lecture opens by defining a method as a block of code designed to perform a specific task that runs only when called. On-screen text states: 'A method is a block of code designed to perform a specific task. It runs only when you call (invoke) it.' The instructor uses the analogy 'Think of a method as a calculator button' and lists reasons to use methods: Code Reusability, Easy Maintenance, Better Organization, and Improved Readability. The general syntax returnType methodName(parameter1, parameter2) is displayed, with the instructor annotating the title with 'Revision' and 'Function' to connect to prior knowledge.

  2. 2:00 – 5:00 02:00-05:00

    The instructor elaborates on method components, explaining that the return type specifies the data type returned and that a return statement is required if the return type is not void. The syntax template returnType methodName(parameter1, parameter2) { return value; } is annotated with 'Student' above the return type and 'EmpDetails' above the parameters to illustrate concrete usage. The lesson transitions to a practical Java example defining void add(int a, int b), where the method call c.add(10, 20) is circled to show actual arguments, and the output 30 is displayed, connecting formal parameters in the declaration to actual arguments in the call.

  3. 5:00 – 10:00 05:00-10:00

    A comparison table titled 'Predefined Vs. User defined function' contrasts library methods with custom methods across rows for Meaning, Purpose, Implementation, Usage, Example, and Code Example. The predefined example Math.max(10, 20) and the user-defined example add(10, 20) are circled in red, with an arrow linking the user-defined call to its code panel. The right code panel shows static int add(int a, int b) printing add(10, 20) with '// Output: 30'. The lesson then introduces Variable Arguments (Varargs), displaying the syntax returnType methodName(dataType... variable) and a sum(int... numbers) method, with an Output panel showing 30 and 100.

  4. 10:00 – 14:31 10:00-14:31

    The varargs concept is reinforced with the on-screen definition: 'Varargs allows a method to accept a variable number of arguments of the same data type.' The code example static int sum(int... numbers) is called with sum(10, 20, 30, 40), and the instructor highlights that varargs is represented using ... (three dots) and is treated internally as an array. Important points about varargs syntax and rules are listed, and the instructor points to the code and output to demonstrate how a single method can accept different numbers of arguments of the same data type.

The lecture progresses from conceptual definition to practical application. It begins with the abstract idea of a method as a reusable code block, justified by four benefits and illustrated with a calculator-button analogy. The syntax is broken into components (return type, method name, parameters, return statement), then grounded in a working add method example that produces output 30. The predefined-versus-user-defined comparison table consolidates understanding by contrasting library methods like Math.max with custom methods. The final segment extends the concept to varargs, showing how the three-dot syntax enables flexible argument counts. Key exam-relevant points include: methods run only when invoked, return statements are required for non-void methods, formal parameters map to actual arguments at call time, and varargs parameters are internally arrays of a single data type.

Loading lesson…