Skip to main content

Posts

Showing posts from October, 2025

Unit 3 Java

Java Methods A method in Java is a block of code that performs a specific task and executes only when it is called (invoked) . It helps in reusing code by defining a logic once and calling it multiple times whenever required. Methods are also known as functions in other programming languages such as C or C++.   Purpose of Methods The main goals of using methods in Java are: Perform specific tasks: Each method handles one defined operation, like calculation or displaying data. Avoid code repetition: The same logic can be reused by calling the method instead of rewriting it. Make programs modular and readable: Dividing a program into smaller methods makes it easier to understand and debug. Improve code reusability: Once defined, a method can be used in different parts of the program or other classes.   Types of Methods in Java There are two main types of methods: 1.       Predefined Methods (Built-in Methods) 2. ...
 Unit -4 String in C# A string is an object of type String whose value is text.  Strings are used for storing text. A string variable contains a collection of characters surrounded by double quotes: There's no null-terminating character at the end of a C# string; therefore a C# string can contain any number of embedded null characters ('\0'). The Length property of a string represents the number of Char objects it contains. using System;   namespace CsharpString {     class Test {     public static void Main(string [] args) {       // create string       string str1 = "C# Programming";       string str2 = "Programing";       // print string       Console.WriteLine(str1);       Console.WriteLine(str2);       Console.ReadLine();     }   }  } Creating a String Object We can use the string keyword to declare a string variab...