Skip to main content

What is Java?

Java is the high-level, object-oriented, robust, secure, platform-independent, high performance, Multithreaded, and portable programming language. It can also be known as the platform as it provides its own JRE and API.

  • Java is an object-oriented computer language.
  • It is a high-level programming language developed by James Gosling in Sun Microsystem in 1995.
  • Java is a fast, secure and reliable language used for many games, devices and applications.

What is collection class in Java? List down its methods and interfaces.

In Java, the collection is a framework that acts as an architecture for storing and manipulating a group of objects. Using Collections you can perform various tasks like searching, sorting, insertion, manipulation, deletion, etc. Java collection framework includes the following:

  • Interfaces
  • Classes
  • Methods

Difference between argument and parameter in Java?

You might have noticed that several people use argument and parameter interchangeably. This function has 2 arguments and it takes 2 parameters sounds the same but logically it is different.

A parameter is a variable in a method declaration and arguments are the data you pass into the method's parameters when you call a method. In another words Argument is the actual value of the variable.

Consider below example, In this example xParam and yParam are parameters and xArg and yArg are the arguments.

public void sum(int xParam, int yParam)
{
}

String xArg = 1;
String yArg = 2;
myClass.sum(xArg, yArg); 

In C++ arguments are actual parameters and parameters which used in function declaration are called formal parameters.

What will be the output of below Java code?

Example Code 1: 

public interface  A  
{	
    public void m1();
    public void m2();
}

class B implements A
{
    public void m1()
    {	
    }
}

Output: compile-time error:- The type B must implement the inherited abstract method A.m2()

Example Code 2: 

public interface A  
{
    public void m1();
    public void m2();
}

abstract class B implements A
{
    public void m1()
    {
        System.out.println("Vinay");
    }
}

class C extends B
{
    public void m2()
    {
        System.out.println("Method2 value from the class C");
    }
    public void m1()
    {
        System.out.println("Method1 value from the class C");
    }

    public static void main(String[] args)
    {
        C c=new C();
        c.m1();
        c.m2();

        B b=new C();
        b.m1();
        b.m2();

        A a=new C();
        a.m1();
        a.m2();
    }
}

Output:

Method1 value from the class C

Method2 value from the class C

Method1 value from the class C

Method2 value from the class C

Method1 value from the class C

Method2 value from the class C

About

Elix is a premium wordpress theme for portfolio, freelancer, design agencies and a wide range of other design institutions.