OOP PRELIMS to Pre-Finals Exam

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/34

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

35 Terms

1
New cards

This keyword is used when a method is NOT allowed to be overriden by a subclass.

final

2
New cards

Which of the following access modifiers is the least restrictive?

public

3
New cards

Which of the following statements is NOT TRUE?

A static method can access an intance method.

4
New cards

Which package modifier is the most restrictive?

private

5
New cards

Which of the following keywords indicates that the method will NOT return a value?

void

6
New cards

Which modifier allows access to the subclass of the class?

protected

7
New cards

Which of the following is optional in a method declaration?

Access modifier

8
New cards

These are the variables listed in a method declaration.

Parameters

9
New cards

This keyword is used when a method DOES NOT have a body.

abstract

10
New cards

This occurs when a primitive type is instantly converted to its object wrapper class.

Autoboxing

11
New cards

It consists of the method’s name and parameter types.

Signature

12
New cards

This method belongs to the class rather than the object of a class.

Static Method

13
New cards

What occurs when a method has the same name with another method but has a different parameter types?

Overloading

14
New cards

These are the actual values that are passed in when a method is invoked.

Arguments

15
New cards

Which modifier grants access only to members of its own class?

private

16
New cards

What is the output of the code below?

public class Apple {

static String color = “red”;

Apple apple = new Apple();

apple.color = “green”;

System.out.println(apple.color);

}

}

green

17
New cards

What is the output of the colde below?

public class Test {

private static void add(int i, int j) {

System.out.println(“int”);

}

private static void add(Integer i, Integer j) {

System.out.println(“Integer”);

}

public static void main(String[] args) {

add(10, 20);

}

}

int

18
New cards

What is the result of the code below?

public class HowMany {

public int add(int one, int two){

return one + two;

}

public static void main(String[] args) {

HowMany h = new HowMany();

int result = h.add(2, 3);

System.out.println(result);

}

5

19
New cards

Which of the following will compile succesfully?

final static void methodA() { }

20
New cards

Which of the following method declaration is correct?

boolean isCorrect() {

return true;

}

21
New cards

Which line leads to compilation error?

public class Prelim {

System.out.println(count);

}

public static void main(String[]args){

Prelim.displayMsg();

}

}

System.out.println(count);

22
New cards

What is true in the following statement?

student.report(course);

report is the method name.

23
New cards

What is the result of the code below?

public class Test {

private static void add(Double i, Double j) {

System.out.println(“Double”);

}

private static void add(float i, float j) {

System.out.println(“float”);

}

public static void main(String[] args) {

add(5.0, 10.0);

}

}

Double

24
New cards

Which of the following will compile successfully?

public int methodC() { return 0; }

25
New cards

Which of the following is a valid method declaration in Java?

public int compute(int a, int b) { return a + b; }

26
New cards

Why will the code below NOT compile?

class Caller {

private void start() {

System.out.print(“Started”);

c.start();

}

}

The start() method is private.

27
New cards

What is the output of the code below?

public class Test {

static void m(int x) {

System.out.println(“int”);

}

static void m(char x) {

System.out.println(“char”);

}

public static void main(String [] args) {

int i = 5;

m(‘5’);

}

}

char

28
New cards

Which of the following can fit the missing statement?

public class Prelim {

____void method() { }

}

final

29
New cards

Which of the following statements declares a constant field?

final static int x = 10;

30
New cards

What is the result of the code below?

public class Test {

public String name;

public static void main(String [] args) {

Test obj = new Test();

System.out.println(obj.name);

}

}

null

31
New cards

In the method call calculateTotal(5, 10), what re 5 and 10 reffered to as?

Arguments

32
New cards

Which method header defines a method named convert that takes no parameters and returns an int?

int convert() { }

33
New cards

What will be the result if a method with non-void return type does not include a return statement?

The program will result in a compilation error.

34
New cards

What is true about instance methods?

They can access both static and instance variables.

35
New cards

Which of the following scenarios will result in a compilation error when declaring methods in the same class?

Two methods with the same name, same parameter list, but different return types.