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

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.

24.85%

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

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

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

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

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

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

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

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

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

29.05%

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

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

Object String Object

Object String Object

46.38%

Object Object Object

Object Object Object

10.47%

String String String

String String String

7.73%

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

Hello prepsters : Main

Hello prepsters : Main

67.61%

Compile time error : weaker access privileges

Compile time error : weaker access privileges

15.34%

No output

No output

1.7%

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

20

20

52.54%

Compilation error

Compilation error

14.97%

No output

No output

2.82%

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

No output

No output

8.91%

Compile time error

Compile time error

29.02%

Runtime error

Runtime error

9.2%

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

abstract

abstract

18.11%

final

final

55.41%

static

static

21.62%

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

Compilation error

Compilation error

36.87%

no output

no output

15.04%

Zero(0)

Zero(0)

2.65%

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

100 200

100 200

26.3%

Compilation error

Compilation error

40.06%

No output

No output

2.75%

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.