Quiz6

Quiz6

University

10 Qs

quiz-placeholder

Similar activities

Java Operators

Java Operators

University

14 Qs

for loops & while loops

for loops & while loops

University - Professional Development

10 Qs

Talent Next Java MCQ-1

Talent Next Java MCQ-1

University

10 Qs

exception

exception

University

10 Qs

Methods

Methods

University

10 Qs

Java Methods

Java Methods

University

14 Qs

GDSC

GDSC

University

10 Qs

OOP - Java Classes

OOP - Java Classes

12th Grade - University

15 Qs

Quiz6

Quiz6

Assessment

Quiz

Computers

University

Hard

Created by

Ms. Asst.Prof

Used 1+ times

FREE Resource

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

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?