Competitive Programming Lab Quiz- 4B

Competitive Programming Lab Quiz- 4B

20 Qs

quiz-placeholder

Similar activities

time

time

6th Grade

15 Qs

Perkins CXL Quiz

Perkins CXL Quiz

KG - University

15 Qs

percent equation

percent equation

8th Grade

15 Qs

почему белка это не енот?

почему белка это не енот?

KG - University

15 Qs

OC training Test

OC training Test

KG - University

17 Qs

Recruitment: 1st Year Tier Avibhuj Squad

Recruitment: 1st Year Tier Avibhuj Squad

KG - University

15 Qs

Tech Genius II

Tech Genius II

KG - University

20 Qs

KNOW YOUR COUNTERPARTY (KYC) TRAINING

KNOW YOUR COUNTERPARTY (KYC) TRAINING

KG - University

20 Qs

Competitive Programming Lab Quiz- 4B

Competitive Programming Lab Quiz- 4B

Assessment

Quiz

Hard

Created by

Chayapathi R

Used 7+ times

FREE Resource

20 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

public class Solution{

       public static void main(String[] args){

                     short x = 10;

                     x =  x * 5;

                     System.out.print(x);

       }

}

The code will print 50
The code will print 10

compilation Error

Generates Exception

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

public class Solution{

       public static void main(String[] args){

               int[]  x = {120, 200, 016};

               for(int i = 0; i < x.length; i++){

                        System.out.print(x[i] + “ “);

               }                  

       }

}

120 200 16
120 200 016
120 200 14

none

3.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Identify the correct restriction on static methods.

  1. I. They must access only static data

  2. II. They can only call other static methods.

  3. III. They cannot refer to this or super.

I and II

II and III

Only III

All of the above

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

public class ArraysInJava

{

public static void main(String[] args)

{

int[] i = new int[-1];

i[1]=20;

System.out.println(i[1]);

}

}

This code will compile and run without any issues with the output 20

This code will throw an ArrayIndexOutOfBoundsException
This code will throw a NegativeArraySizeException
This code will throw a NullPointerException

5.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Identify the corrected definition of a package.

 

A package is a collection of editing tools

A package is a collection of classes

A package is a collection of classes and interfaces

A package is a collection of interfaces

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of following Java code?

public class Main {

  public static void main(String arg[]) {

    int i;

    for (i = 1; i <= 12; i += 2) {

      if (i == 8) {

        System.out.println(i);

        break;

      }

    }

  }

}

8
1, 3, 5, 7, 9, 11
1, 3, 5, 7
No output

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

import java.util.Scanner;

 

class ThisKeyword {

  private int a = 4;

  private int b = 1;

 

  void getSum(int a, int b) {

    this.a = a;

    this.b = b;

    System.out.println(this.a + this.b);

  }

}

 

public class Main {

  public static void main(String args[]) {

    ThisKeyword T = new ThisKeyword();

    T.getSum(3, 5);

  }

}

The output will be 8
The output will be 5
The output will be 9
The output will be 7

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?