Methods in Java

Duration: 15 min

This video lesson is available to enrolled students.

Return to /learn/RPSC-PROGRAMMER/paper-2-programming-language-java/oops-with-java/classes-objects/asset-methods-in-java-25115 after enrolling

Inside: a video lesson and guided study material.

Module outline

  1. Paper 1 | Reasoning Test: Series (Number and Letter Series) (Numerical Relations and Reasoning), Coding Decoding, Data Sufficiency, Syllogisms, Deductive and Inductive Reasoning (Logical Deduction and Induction) (Prepositional Reasoning), Seating Arrangements, Blood Relations, Puzzle Solving (Puzzles), Venn Diagram, Analogy, Ranking, Order and Sequence, Non Verbal Reasoning (Spatial Aptitude) (Spatial Reasoning) (Visual Reasoning), Selection Decision Table (Decision Making), Logical Sequence Of Words, Cubes & Dices, Analytical Reasoning (Counting Figures Reasoning), Calendar, Alphabet and Word Tests, Numerical Reasoning, Number System, Averages, Mixtures and Alligation, Percentages, Series Completion, Analogy and Classification, Patterns in Two-Dimensional Figures, Coding and Decoding, Mathematical Operations, Direction Sense, Algebra, Logical Deduction and Induction, Syllogisms and Venn Diagrams, Critical Reasoning, Order, Ranking and Sequence, Reading Comprehension, Profit, Loss and Discount, Constraint Puzzles, Speed, Time and Distance, Traverse Surveying, Ratio and Proportion, Time and Work, Mensuration, Permutations and Combinations, Clocks and Calendars, Data Interpretation, Assembling and Grouping of Shapes, Transformation of Shapes, Three-Dimensional Patterns and Visualization, Cubes and Dice, Vocabulary, Blood Relations, Data Sufficiency
  2. Paper 1 | Numerical Analysis: Number System, HCF LCM, Percentage, Ratio and Proportion (Ratios), Average, Sequence and Series (Series), Powers and Exponents (Surds and Indices), Algebra, Statistics, Data Interpretation, Mental Ability, Arithmetic, Logarithm, Profit and Loss, Simple Interest and Compound Interest, Speed Time and Distance, Mixture and Alligation, Mensuration and Geometry, Permutation and Combination, Probability, Sequences and Series, Powers, Surds and Logarithms, Subject-Verb Agreement, Sentence Completion, Geometry, Sentence Structure and Correction, Data Sufficiency, Trigonometry, Measurement and Quantity Take-Off, Signal Space and Optimum Detection, Probability, Statistics, Algebra, Time and Work, Speed, Time and Distance, Data Interpretation, Graph Theory, Combinatorics
  3. Paper 1 | General Knowledge: State Wise GK, History, Geography, GK- Current Affairs, Static General Knowledge, Polity, Indian Economy
  4. Paper 1 | DBMS: Basics of DBMS, ER Diagram, Relational Model & Functional Dependencies, Keys & Integrity Constraints, Normalization (1NF - BCNF), Decomposition Properties & 4NF, File Organization & Indexing, Relational Algebra, SQL, Transaction Management, Concurrency Control, Relational Calculus, Database Security & Authorization, Database Recovery
  5. Paper 1 | Data Communication & Network: Introduction to CN, Data Communication, DLL: Access Control, DLL: Flow Control, DLL: Error Control, DLL: Framing, Data Link Layer - Ethernet, Net Layer: IPv4 & Proto, Net Layer: IP Addressing, Net Layer:Routing Protocol, Transport Layer Services, TL: Congestion & UDP, Application Layer, Network Security, Security in Mobile and Wireless Computing, Input Output Organisation, File Management, Hardware Basics, Terms & Abbreviations, Protocols & Services, Network Access Technologies, Cyber Safety and Security, Basics of COA
  6. Paper 2 | System Analysis & Design: Fundamentals of Systems and Information Systems, SDLC and Development Approaches, Fundamentals of Software Engineering, Software Requirements and Quality Assurance, Software Documentation and Software Requirements Specification (SRS), SDD and Quality Assurance, Software Design, Estimation and Metrics, Software Testing, Software Maintenance and Configuration Management, Security, Risk Management & Maintenance, extras
  7. Paper 2 | Programming Language (Java): Java Fundamentals, OOPS with Java, Array, String, IO & References, Generic & Collections, Multithreading, Java, Miscellaneous, Control Flow, OOPS with C++, Stack, C Fundamentals, Arrays & Pointers, Object Oriented Technology, Control Flow & Looping, Introduction to Python
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…