InfyTQ Questions and Answers | Java Certification Round

InfyTQ Java MCQ Questions and Solutions for 2024 graduates

InfyTQ has been announced for 2024 passing graduates. This year InfyTQ Certification Exam will have 2 selection rounds.

  1.  Certification Round
  2. Advantage Round

The Certification Round consists of Java MCQ and Hands on Coding Questions. There will be 10 Java MCQ Questions and 2 coding questions if you opt for Java programming language while booking the slot.

Here we have provided sample practice questions for Java MCQ Questions Round based on previous year questions papers and sample test.

InfyTQ Java MCQ Round Questions

InfyTQ Online Test Pattern:-

Name Of The SectionNumber Of Questions
Hands-on coding2 Ques
DBMS10 Ques
Programming( JAVA or Python)10 Ques
Coding3 Ques

InfyTQ Java MCQ Round Practice Questions

Question 1 – Which of the following main method declarations are valid?

Options

  1. public static void main(String args){}
  2. public synchronized final strictfp void main(String[] args){}
  3. public static int main(String… args){}
  4. public static synchronized final strictfp void main(String… args){}

Answer- public static synchronized final strictfp void main(String… args){}

Explanation –

  • public static void main(String args){} // incorrect because the main function does not contain String[] as an argument.
  • public synchronized final strictfp void main(String[] args){} // incorrect because static keyword is missing.
  • public static int main(String… args){} //incorrect because we can’t take int as a return type.
  • public static synchronized final strictfp void main(String… args){}// valid

 

Question 2 – What is the range of boolean data type in java?

Options

  1. -128 to 127
  2. -32768 to 32767
  3. 0 to 65535
  4. Not Applicable

Answer- Not Applicable

Explanation –The range of boolean data type is not applicable but allowed values are true or false.

 

Question 3 – Which data type is best suited to represent the logical values?

Options

  1. Integer
  2. Character
  3. Boolean
  4. All of the mentioned above

Answer- Boolean

Explanation – Boolean data type is best suited to represent the logical values.

 

Question 4 – Two methods with the same name but different argument types are known as?

Options

  1. Method overloading
  2. Method overriding
  3. Both A and B
  4. All of the mentioned above

Answer- Method overloading

Explanation –Methods with the same name and different argument type are known as method overloading.

 

Question 5 – The subclass constructor uses the ———keyword to invoke the constructor of the superclass.

Options

  1. Super
  2. Final
  3. Static
  4. Public

Answer- Super

Explanation –Super keyword is used by the subclass for invoking the superclass constructor.

 

Question 6 – Which of the following is a correct way to create an object of class Test?

Options

  1. Test t=new Test();
  2. Test t=new Test;
  3. t=new Test();
  4. new Test t;

Answer- Test t=new Test();

Explanation – Test t=new Test()  ,is the correct syntax for creating objects in java.

 

Question 7 – What will be the output of the following java program?

class Parent 
{
     int x=10;
}
class Child extends Parent
{
     int x=20;
}
class Test
{
	public static void main(String[] args)
	{
		Parent p=new Parent();
		System.out.print(p.x+” ”);
		Child c=new Child();
		System.out.print(c.x+” ”);
		Parent p1=new Child();
		System.out.print(p1.x);
	}
}

Options

  1. 10 20 20
  2. 10 20 10
  3. 10 10 10
  4. 20 20 20

Answer- 10 20 10

Explanation – Overriding concept is not applicable for variables. Hence variable resolution is always taken care of by the compiler based on reference type.So the answer is 10 20 10.

 

Question 8 – How many reserved words are there in java?

Options

  1. 20
  2. 32
  3. 40
  4. 52

Answer- 52

Explanation – There are 52 reserved words in java.

 

Question 9 – What will be the output of the following program?

public class Main
{
    public static void main (String args[])
    {
        int x = 0;
        if (x)
        {
	        System.out.println ("if");
        }
        else
        {
	        System.out.println ("else");
        }
    }
}

 

Options

  1. if
  2. else
  3. compile time error
  4. no output

Answer- Compile time error

Explanation – The argument to the if statement should be Boolean if we are providing any other type we will get “compile time error”.Here, in the above code the argument type is int so we will get a compile time error :- “int cannot be converted to boolean”.

 

 

Question 10 – What is the output of the following code snippet?

public class Question {
   public static void main (String [ ] args) {
           int var = 22, anotherVar = 7, result ;
           String str = “One” ;
           String anotherStr = “Two” ;
           result = var*anotherVar / anotherVar ;
           if ( result < 22 ) {
                System.out.println(str) ;
           }
           else {
                     System.out.println(anotherStr) ;
           }
    }
}

 

Options

  1. Compilation error: incorrect use of operators
  2. One
  3. Two
  4. No Output

Answer- Two

Explanation –  Here the main equation to be concentrated is → result = var*anotherVar / anotherVar ; var has the value 22 in it and anotherVar has the value 7 so the equation can be written as 24*7/7, but because of BODMAS 7/7 will be executed first which will result in 1 and this will be considered for multiplication as 22*1 which gives us 22. So the final value which is stored in the variable result is 22. While checking if condition 22>22 will be a False and hence anotherStr which has the value “Two” will be printed as the output.