Cognizant GenC Next OOPs Questions

GenC Next OOPs Questions 2023

Cognizant GenC Next OOPs Sections is one of the most important section for Genc next 2023 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.56%

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.43%

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.

14.32%

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

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

7.69%

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.29%

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.89%

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.18%

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.

9.64%

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

29.56%

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

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

15.27%

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

28.82%

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.35%

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

35.64%

Object String Object

Object String Object

46.41%

Object Object Object

Object Object Object

10.26%

String String String

String String String

7.69%

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

15.32%

Hello prepsters : Main

Hello prepsters : Main

67.63%

Compile time error : weaker access privileges

Compile time error : weaker access privileges

15.32%

No output

No output

1.73%

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

29.8%

20

20

53.01%

Compilation error

Compilation error

14.33%

No output

No output

2.87%

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

52.34%

No output

No output

9.06%

Compile time error

Compile time error

29.24%

Runtime error

Runtime error

9.36%

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

4.93%

abstract

abstract

18.36%

final

final

55.62%

static

static

21.1%

In any object-oriented programming language, Overriding is a feature that allows a subclass or child class to provide a specific implementation of a method that is already provided by one of its super-classes or parent classes.
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

45.35%

Compilation error

Compilation error

36.94%

no output

no output

15.02%

Zero(0)

Zero(0)

2.7%

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

30.53%

100 200

100 200

26.17%

Compilation error

Compilation error

40.5%

No output

No output

2.8%

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.