• Slider Banner

    Prepare for

    Technical Interview

    Over .1 Million+ Interview Questions for different profiles

    Read More
  • Slider Banner

    Join the

    Programming World

    Learn about top programming languages, tools and frameworks.

    Read More
  • Slider Banner

    Prepare with

    Certification MCQ

    Practice for certification from 1000+ multiple choice questions.

    Read More

What is Protractor?

Protractor is an end-to-end test framework for Angular and Angular JS applications. Protractor runs tests against your application running in a real browser, interacting with it as a user would. Protractor is a node.js port of the webdriver.io, which is the JavaScript implementation of Selenium framework.

Protractor is a Node.js program that supports test frameworks like Jasmine, Mocha, and Cucumber.

What will be the output of below Java code?

Example Code: 

public class A
{
    int i = 999;
    System.out.println(i);
}

public class B extends A
{
    int i = 777;
    System.out.println(i);
}

public class C extends B
{
    int i = 888;
    System.out.println(i);
}

public class Test
{
    public void main(String args[])
    {
        C c = new C();
        c.i;               //Line :- 1
       ((B)c).i;        //Line :-2
       ((A)(B)c).i;   //Line :- 3
    }
}

Output

Line 1:- 888
Line 2:- 777
Line 3:- 999

What will be the output of below Java code?

Example Code: 

public class A
{
    public static void m1()
    {
        System.out.println("A")
    }
}

public class B extend A
{
    public static void m1()
    {
        System.out.println("B");
    }
}

public class C extends B
{
    public static void m1()
    {
        System.out.println("C");
    }
}

public class Test
{
    public void main(String args[])
    {
        C c = new C();
        c.m1();           //Line :- 1
       (B)c.m1();        //Line :-2
       (A)(B)c.m1();   //Line :- 3
    }
}

Output
Line 1:- C
Line 2:- B
Line 3:- A

Note:- Because in the method hiding concept, Method resolution is based on a compile-time object reference.

What will be the output of below Java code?

Example Code: 

public class A
{
    public void m1()
    {
        System.out.println("A");
    }
}

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

public class C extends B
{
    public void m1()
    {
        System.out.println("C");
    }
}

public class Test
{
    public void main(String args[])
    {
        C c new C();
        
        c.m1();           //Line: 1
        (B)c.m1();       //Line: 2
        (A)(B)c.m1();  //Line: 3
    }
}

Output: 
Line 1: C
Line 2: C
Line 3: C

What are the rules for the Type Casting in Java?

Type casting is when you assign a value of one primitive data type to another type.

B b = new B();
A a = (A)b;

Rules:

  • There must be some relation between A and B, it can be parent and child relationship.
  • Type of (A)b must be the A or derived object of A.

Example

String s = new String("Durga");
Object o = (Object)s;

What is coupling in Java?

The degree of dependency between the components is called coupling. There are two types of coupling in java:-

1. Tight coupling: Degree of dependency between components is high that is called tight coupling. In general, Tight coupling means the two classes often change together. In other words, if A knows more than it should about the way in which B was implemented, then A and B are tightly coupled.

When an object creates the object to be used, then it is a tight coupling situation. As the main object creates the object itself, this object can not be changed from outside world easily marked it as tightly coupled objects.

Example:

class Subject 
{
    Topic t = new Topic(); 

    public void startReading()
    {
        t.understand();
    } 
} 

class Topic
{
    public void understand()
    {
        System.out.println("Tight coupling concept");
    }
}

In the above program the Subject class is dependents on Topic class. In the above program Subject class is tightly coupled with Topic class it means if any change in the Topic class requires Subject class to change. For example, if Topic class understand() method change to gotit() method then you have to change the startReading() method will call gotit() method instead of calling understand() method.

2. Loose coupling: Degree of dependency between components is low that is called loose coupling. Loose coupling is the best choice of coding.

When an object gets the object to be used from the outside, then it is a loose coupling situation. As the main object is merely using the object, this object can be changed from the outside world easily marked it as loosely coupled objects.

Example:

public interface Topic 
{
    void understand(); 
} 

class Topic1 implements Topic
{
    public void understand()
    {
        System.out.println("Got it");
    }
} 

class Topic2 implements Topic
{
    public void unserstand()
    {
        System.out.println("understand");
    } 
}

public class Subject
{
    public static void main(String[] args)
    {
        Topic t = new Topic1();
        t.understand();
    }
} 

In the above example, Topic1 and Topic2 objects are loosely coupled. It means Topic is an interface and we can inject any of the implemented classes at run time and we can provide service to the end user.

What is inheritance in Java?

Inheritance in Java is the concept where the properties of one class can be inherited by the other. It helps to reuse the code and establish a relationship between different classes. Inheritance is performed between two types of classes:

  • Parent class (Super or Base class)
  • Child class (Subclass or Derived class)

A class which inherits the properties is known as Child Class whereas a class whose properties are inherited is known as Parent class.

What is the meaning of Steps in Cucumber tool?

The steps are sequences which help in describing how exactly the test scenario will take place. It also defines the preconditions of the test scenario. It consists of the following commands or keywords- 

  • Given - Before starting the tests, all of its conditions is described by this. 
  • When - The actions during Cucumber tests are described by this. 
  • Then - This is the outcome of the actions which took place When.  
  • And - logical representation of the Cucumber test  
  • But - This is same as And but is negative form.  
Subscribe to