Competitive Programming Lab Quiz- 4B

Competitive Programming Lab Quiz- 4B

20 Qs

quiz-placeholder

Similar activities

Personal Shopper

Personal Shopper

KG - University

15 Qs

English 2 REVIEW

English 2 REVIEW

KG - University

15 Qs

numerical patterns input output

numerical patterns input output

5th Grade

15 Qs

STEM Careers: Forensic Science Quiz

STEM Careers: Forensic Science Quiz

12th Grade

15 Qs

Fair and Effective Interview MCQ

Fair and Effective Interview MCQ

KG - University

15 Qs

starr review

starr review

12th Grade

15 Qs

Scientific Investigation

Scientific Investigation

12th Grade

15 Qs

Week 2 Vocabulary Quiz

Week 2 Vocabulary Quiz

10th Grade

15 Qs

Competitive Programming Lab Quiz- 4B

Competitive Programming Lab Quiz- 4B

Assessment

Quiz

Practice Problem

Hard

Created by

Chayapathi R

Used 7+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?