Cognizant GenC Next OOPs Questions

GenC Next OOPs Questions 2022

Cognizant GenC Next OOPs Sections is one of the most important section for Genc next 2022 hiring. This section will asses your object oriented programming concept such as Classes, Objects, Abstraction, encapsulation, Inheritance , Polymorphism (Method Overloading and Method Overriding), Message passing etc. You will face question of OOPs in mcq section as well as in coding section.

Cognizant OOPs Questions
Cognizant OOPs Questions

20 - 25 Question

Total Question

40 minutes

Total Time

1 Mark/Question

Marking Scheme

Cognizant OOPs Questinos

No

Negative Marking

Practice Questions for GenC Next OOPs Round

1. What is a tightly encapsulated class?

A class is said to be tightly encapsulated if and only if every variable of that class is declared as private.

A class is said to be tightly encapsulated if and only if every variable of that class is declared as private.

52.63%

A class is said to be tightly encapsulated if and only if every function of that class is declared as private.

A class is said to be tightly encapsulated if and only if every function of that class is declared as private.

25.39%

A class is said to be tightly encapsulated if and only if every variable of that class is declared as protected.

A class is said to be tightly encapsulated if and only if every variable of that class is declared as protected.

13.31%

A normal java class can also be called as tightly encapsulated class.

A normal java class can also be called as tightly encapsulated class.

8.67%

A class is said to be tightly encapsulated if and only if every variable of that class is declared as private whether the variable has getter and setter methods or not and whether these methods declared as public or not, no required to check.

 

2.

public class Plant
{
    private String name;
    public Plant (String name)
    {
        this.name = name;
    }

    public String getName ()
    {
        return name;
    }

}

public class Tree extends Plant
{
    public void growFruit ()
    {
    } 
    
    public void dropLeaves ()
    {
    } 
}

which statement is true?

The code will compile without changes.

The code will compile without changes.

52.9%

The code will compile if public Tree() { Plant();} is added to the Tree class.

The code will compile if public Tree() { Plant();} is added to the Tree class.

22.87%

The code will compile if public Plant(){ Tree();} is added to the Plant class.

The code will compile if public Plant(){ Tree();} is added to the Plant class.

15.36%

The code will compile if public Plant(){ this("fern");} is added to the Plant class.

The code will compile if public Plant(){ this("fern");} is added to the Plant class.

8.87%

By default the child class constructor calls the zero argument constructor of the parent class.

3. When Overloading does not occur?

More than one method with same name but different method signature and different number or type of parameters

More than one method with same name but different method signature and different number or type of parameters

30.31%

More than one method with same name, same signature but different number of signature

More than one method with same name, same signature but different number of signature

16.38%

More than one method with same name, same signature, same number of parameters but different type

More than one method with same name, same signature, same number of parameters but different type

26.83%

More than one method with same name, same number of parameters and type but different signature

More than one method with same name, same number of parameters and type but different signature

26.48%

Overloading occurs when more than one method with same name but different constructor and also when same signature but different number of parameters and/or parameter type.

4. What will be the output of the following program?

class Main 
{
    public void func (String s) 
    {
        System.out.print ("String ");
    } 
    
    public void func (Object o) 
    {   
        System.out.print ("Object ");   
    }
    
    public static void main (String[]args) 
    {
        Main obj = new Main ();
        obj.func (new Object ());
        obj.func ("Prepinsta");
        obj.func (null);
    } 
}

Object String String

Object String String

33.08%

Object String Object

Object String Object

50%

Object Object Object

Object Object Object

10.53%

String String String

String String String

6.39%

In overloading, the child class will always get high priority then parent class.

5. What will be the output of the following program?

class Sample 
{
    public void func () 
    {
        System.out.println ("Hello Prepsters : Sample");
    } 
} 

public class Main extends Sample 
{
    protected void func () 
    {
        System.out.println ("Hello prepsters : Main");
    } 
    public static void main (String[]args)
    {
        Main m = new Main ();
        m.func ();
    } 
}

Hello prepsters: Sample

Hello prepsters: Sample

14%

Hello prepsters : Main

Hello prepsters : Main

71.2%

Compile time error : weaker access privileges

Compile time error : weaker access privileges

12.4%

No output

No output

2.4%

While overriding we can’t reduce the scope of access modifiers.

6. What will be the output of the following program?

class Sample 
{
    int a = 10;
} 

public class Main extends Sample 
{
    int a = 20;
    public static void main (String[]args)
    {
        Sample s = new Main ();
        System.out.println (s.a);
    } 
}

10

10

30.2%

20

20

54.51%

Compilation error

Compilation error

12.94%

No output

No output

2.35%

Overriding concept is not applicable for variables. Variable resolution is always takes care by the compiler based on reference type.

7. What will be the output of the following program?

public class Main 
{
    Main () 
    {
        System.out.println ("Constructor");
        super ();
    }
   
    public static void main (String[]args)
    {
        Main m = new Main ();   
    } 
}

Constructor

Constructor

53.39%

No output

No output

8.37%

Compile time error

Compile time error

29.08%

Runtime error

Runtime error

9.16%

We have to take super() or this() only in the first line of the constructor. If we are taking anywhere else we will get a compile time error.

8. ------------------keyword does not allow a method to be overridden in the subclass.

public

public

3.01%

abstract

abstract

17.67%

final

final

56.39%

static

static

22.93%

Final keyword does not allow a method to be overridden in the subclass.

9. What will be the output of the following program?

public class Main 
{
    final int i;
    public void func ()
    {
        i = 100;
    } 
    
    public static void main (String[]args) 
    {
        Main m = new Main ();
        System.out.println (m.i);
    } 
}

100

100

47.3%

Compilation error

Compilation error

37.76%

no output

no output

14.94%

For the final instance variable we should perform initialization before constructor completion i.e.
1)at the time of declaration
2)inside instance block
3)inside the constructor.

10. What will be the output of the following program?

public class Main 
{
    public static void func (final int a, int b) 
    {
        a = 200;
        b = 100;
        System.out.println (a + " " + b);
    }
    public static void main (String[]args) 
    {
        func (100, 200);
    } 
}

200 100

200 100

28.33%

100 200

100 200

28.33%

Compilation error

Compilation error

40.77%

No output

No output

2.58%

If we declare formal parameters as final then we can’t change its value within the method.

×

Please login to report

Preparation Material for GenC Next OOPs Section 2021-22

Below are all the topics mentioned from which you can expect MCQ Questions in Section 1 of the hiring test. 

  • Classes
  • Objects
  • Abstraction
  • Encapsulation
  • Inheritance
  • Polymorphism
    • Method Overloading
    • Method Overriding
  • Message passing

GenC Next OOPs Section Details

OOPs SectionGenC Next
Number of Questions20 – 25 Questions
Time Limit40 Mins
DifficultyMedium
Negative MarkingNo

FAQs about Cognizant GenC Next

What is the sectional cut off for this Section?

There is no sectional cut-off, however it is mandatory that you get at least 18-20 questions right from the pack of 20-25 questions in the MCQ section to get a higher overall score

What is the difficulty level of Cognizant Genc next exam?

The GenC Next hiring exam is commparatively of higher difficulty level than the normal GenC exam. This hiring process is mainly focused for hiring coding proficient students, hence the package offered of GenC next is also higher than GenC.

What is the package offered for Cognizant Genc next exam?

The package offered for GenC Next candidates is 6.75 LPA

WILL I GET ANY OTHER ROLE IF NOT FOUND SUITABLE FOR GENC NEXT

Yes, you will get GenC Elevate role according to your performance in skill based assessment and final interview.

WHAT ARE ALL THE ROUNDS IN COGNIZANT GENC NEXT EXAM?

Skill based assessment followed by technical/HR interview.