Search Header Logo

Quiz6

Authored by Ms. Asst.Prof

Computers

University

Used 1+ times

Quiz6
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the below code?

public static void main(String args[]) {

short number = 32767;

short numberTwo = (short)(number + 1);

System.out .println(numberTwo);

compilation error: cannot convert from int to short

32767

32768

-32768

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

If an arithmetic expression contains variables of int, byte and short data types, what will be the data type of its result?

int

byte

float

short

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the below code?

public class Tester {

public boolean checkTemp(int temp) / if (temp > 100) (

return true;

} else {

return false;

}

public static void main(String args []) {

Tester tester » new Tester ();

if (tester.checkTemp(110)) {

System.out.println("Data is valid");

else {

System.out.printin("Data is invalid");

Data is invalid

Data is valid

true

false

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

public class Tester {

pudlic void demoMethod()

int varone = 1000;

float varTwo = 20.00f;

double varThree = 0.0;

varThree = (double) (varTwo + varone * (7.0 / 100));

System.out.println("varThree:" + varThree);

)

public static void main(String args []) {

Tester tester = new Tester();

tester.demoMethod ();

varThree:20.0

varThree:90.0

varThree:1020.0

varThree:0.0

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will the output of the below code?

public class Tester {

public int subtract(int a, int b) {

return (a - b);

public static void main(String args[]) {

int a = 10;

int b = 20;

Tester tester = new Tester ();

int res • tester.subtract(b, a);

System.out.print]n(res);

0

-10

10

Compilation error: the name of the formal and actual parameters must be the same

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Identify the number of instances and local variables present in the Student class given below.

public class Student {

public int rollNo;

public string studentName;

public void findGrade(int marks) {

char grade;

if (marks > 90)

grade = 'A';

else if (marks < 90 && marks > 80)

grade = 'B';

else if (marks < 80 && marks > 70)

grade = 'C';

else

grade = 'D';

System.out.printIn(grade);

}

2 instance variables, 2 local variables

3 instance variables, 1 local variables

2 instance variables, 1 local variables

4 instance variables, 0 local variables

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

public class Tester {

public int add(int a, int b) {

return (a + b);

}

public static void main(String args []) {

int a = 10;

int b = 20;

int sum = 0;

Tester tester = new Tester ();

tester.add(a, b);

System.out.printIn(sum);

}

}

10

0

20

30

Access all questions and much more by creating a free account

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?