Found 9150 Articles for Object Oriented Programming

Difference between Object and Class in Java

Kiran Kumar Panigrahi
Updated on 12-Apr-2025 16:28:00

2K+ Views

Java is an object-oriented programming language, which means that everything in Java is represented as a class and object. Every entity with state and behavior is an object. And, classes are the templates to create objects. It contains data and functions so that it can later be accessed by their objects wherever and whenever they are needed. The main task of objects is to get the data present in the classes or use the functions in those classes to manipulate the data. It is compulsory for a class to have an object. Otherwise, it can't be used. But, an object ... Read More

Java program to display command-line arguments

Govinda Sai
Updated on 07-Nov-2024 17:45:37

13K+ Views

In this article, we will learn how to use command-line arguments in Java. Command-line arguments provide a way to pass information to a program when it is executed from the command line. These arguments are passed to the main method of the Java program as an array of String values, allowing the program to access and use them directly. Problem Statement Given a Java program, the task is to display all of the command-line arguments passed to the program when it is executed. Input Command-line arguments:this is a command line 200 -100Output args[0]: thisargs[1]: isargs[2]: aargs[3]: commandargs[4]: lineargs[5]: 200args[6]: ... Read More

Java API documentation generator

Alshifa Hasnain
Updated on 13-Feb-2025 18:46:55

710 Views

In this article, we will learn about Java API documentation generators. Java API documentation generators automate the process of creating structured and readable documentation for Java projects, making it easier for developers to understand and use APIs. What is a Java API Documentation Generator? A Java API documentation generator is a tool that analyzes Java source code and generates documentation in a structured format, typically HTML, XML, or Markdown. These tools extract comments and annotations from the code and transform them into comprehensive references for developers. Different Java API Documentation Generators The Following are Popular Java API documentation generators − ... Read More

Java strictfp keyword

Shriansh Kumar
Updated on 31-Jul-2024 17:27:39

2K+ Views

The strictfp keyword is a modifier that stands for strict floating point. As the name suggests, it ensures that floating-point operations give the same result on any platform. This keyword was introduced in Java version 1.2. In Java, the floating point precision may vary from one platform to another. The strictfp keyword solves this issue and ensures consistency across all platforms. With the release of Java 17 version, the strictfp keyword is no longer needed. Regardless of whether you use this keyword, the JVM now provides consistent results for floating-point calculations across different platforms. When to use Java strictfp keyword? ... Read More

Call by value and Call by reference in Java

Sravani S
Updated on 07-Nov-2023 04:25:11

68K+ Views

Call by Value means calling a method with a parameter as value. Through this, the argument value is passed to the parameter.While Call by Reference means calling a method with a parameter as a reference. Through this, the argument reference is passed to the parameter.In call by value, the modification done to the parameter passed does not reflect in the caller's scope while in the call by reference, the modification done to the parameter passed are persistent and changes are reflected in the caller's scope.Following is the example of the call by value −The following program shows an example of ... Read More

Single dimensional array in Java

V Jyothi
Updated on 17-Jun-2020 08:12:12

952 Views

Following is a simple example of a single dimensional array.Example Live Demopublic class Tester {    public static void main(String[] args) {       double[] myList = {1.9, 2.9, 3.4, 3.5};       // Print all the array elements       for (double element: myList) {          System.out.print(element + " ");       }    } }Output1.9 2.9 3.4 3.5

Types of Array in Java

varun
Updated on 30-Jul-2019 22:30:21

333 Views

Java supports single dimensional and multidimensional arrays. See the example below:Example Live Demopublic class Tester {    public static void main(String[] args) {       double[] myList = {1.9, 2.9, 3.4, 3.5};       // Print all the array elements       for (double element: myList) {          System.out.print(element + " ");       }       System.out.println();       int[][] multidimensionalArray = { {1,2},{2,3}, {3,4} };       for(int i = 0 ; i < 3 ; i++) {          //row          for(int j = 0 ; j < 2; j++) {             System.out.print(multidimensionalArray[i][j] + " ");          }          System.out.println();       }    } }Output1.9 2.9 3.4 3.5 1 2 2 3 3 4

Advantages and disadvantages of arrays in Java

Prabhas
Updated on 17-Jun-2020 07:50:41

2K+ Views

BenefitsEasier access to any element using the index.Easy to manipulate and store large data.DisadvantagesFixed size. Can not be increased or decrease once declared.Can store a single type of primitives only.

Method of Object class in Java

vanithasree
Updated on 17-Jun-2020 08:02:02

2K+ Views

Following are various methods of Object class −protected Object clone() - Used to create and return a copy of this object. boolean equals(Object obj) - Used to indicate whether some other object is "equal to" this one.protected void finalize() - garbage collector calls this method on an object when it determines that there are no more references to the object.Class getClass() - Used to get the runtime class of this Object.int hashCode() - Used to get a hash code value for the object.void notify() - Used to wake up a single thread that is waiting on this object's monitor.void notifyAll() - ... Read More

java access modifiers with method overriding

Giri Raju
Updated on 24-Feb-2020 06:03:42

6K+ Views

Yes, an overridden method can have a different access modifier but it cannot lower the access scope.The following rules for inherited methods are enforced -Methods declared public in a superclass also must be public in all subclasses.Methods declared protected in a superclass must either be protected or public in subclasses; they cannot be private.Methods declared private are not inherited at all, so there is no rule for them.

Advertisements