OOP

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Can constructors be overloaded in derived class? A) Yes, always B) Yes, if derived class has no constructor C) No, programmer can’t do it D) No, never ANSWER:

A

How can Encapsulation be achieved? A) Using Access Specifiers B) Using only private members C) Using inheritance D) Using Abstraction ANSWER:

A

If a class inheriting an abstract class does not define all of its function then it will be known as? A) Abstract B) A simple class C) Static class D) None of the mentioned ANSWER:

A

If you define both an initializer and a constructor for a class, both of these will execute? A) True B) False ANSWER:

A

In which example will the loop display the numbers from 10 to 5? A) {for (int i=10; i > = 5; i--) {System.out.println(i);}} B) {for (int i=10; i > 6; i--) {System.out.println(i);}} C) {for (int i=10; i > = 4; i--) {System.out.println(i);}} D) {for (int i=10; i > 5; i--) {System.out.println(i);}} ANSWER:

A

What is true about private constructor? A) Private constructor ensures only one instance of a class exist at any point of time B) Private constructor ensures multiple instances of a class exist at any point of time C) Private constructor eases the instantiation of a class D) Private constructor allows creating objects in other classes ANSWER:

A

When does Exceptions in Java arises in code sequence? A) Run Time B) Compilation Time C) Can Occur Any Time D) None of the mentioned ANSWER:

A

Which among the following is false for a constructor? A) Constructors are always user defined B) Constructors doesn’t have a return value C) Constructors are overloaded with different signature D) Constructors may or may not have any arguments being accepted ANSWER:

A

Which of the following is a valid declaration of an object of class Box? A) Box obj = new Box(); B) Box obj = new Box; C) obj = new Box(); D) new Box obj; ANSWER:

A

Which of these is used as a default for a member of a class if no access specifier is used for it? A) Private B) Public C) Public, within its own package D) Protected ANSWER:

A

You have declared a class variable String name, what will the setter for this variable look like? A) public void setName(String newName) B) public String name() C) public String getName() D) public string setName() ANSWER:

A

Abstract class cannot have a constructor? A) True B) False ANSWER:

B

An array of 100 integers can be created using a command like? A) int [100] array; B) int [] array = new int [100]; C) array [100] int; D) int [] array = int 100; ANSWER:

B

Does Java support multiple level inheritance? A) True B) False ANSWER:

B

Pure OOP can be implemented without using class in a program? A) True B) False ANSWER:

B

Select the answer option in which the conditional operator is written correctly? A) {If a < b return a; else return b} B) {If (a < b) return a; else return b} C) {If (a < b) then return a; else return b} D) {If (a < b) return a; : return b} ANSWER: ​

B

The string variables a and b are correctly compared in the expression? A) a == b B) a.equals(b) C) a.length() == b.length() D) a.toUpperCase() == b.toUpperCase() ANSWER:

B

Which of the following pairs are similar? A) Class and object B) Class and structure C) Structure and object D) Structure and functions ANSWER:

B

You have declared a class variable String name, what will the getter for this variable look like? A) public int name() B) public String getName() C) public static getName() D) public void getName(String newName) ANSWER: ​

B

{ int x , y = 1; x = 10; if(x != 10 && x / 0 == 0){ System.out.println(y);} else { System.out.println(++y);}}}? A) 1 B) 2 C) Runtime Error D) Compilation Error ANSWER:

B

Can a square array be created using the view command? A) int [100, 100] array; B) int [100][100] array; C) int [][] array = new array[100][100]; D) int [][] array[100][100]; ANSWER:

C

Each character in a line occupies? A) 1 or 2 byte; B) 2 or 3 byte; C) 2 or 4 byte; D) 3 or 4 byte; ANSWER:

C

If same message is passed to objects of several different classes and all of those can respond in a different way, what is this feature called? A) Inheritance B) Overloading C) Polymorphism D) Overriding ANSWER:

C

What is correct syntax for main method of a java class? A) public static int main(String[] args) B) public int main(String[] args) C) public static void main(String[] args) D) None of the above ANSWER: ​

C

What is false about constructor? A) Constructors cannot be synchronized in Java B) Java does not provide default copy constructor C) Constructor can have a return type D) “this” and “super” can be used in a constructor ANSWER:

C

What is the process by which we can control what parts of a program can access the members of a class? A) Polymorphism B) Abstraction C) Encapsulation D) Recursion ANSWER:

C

What is the return type of a method that does not return any value? A) int B) float C) void D) double ANSWER:

C

Which is not feature of OOP in general definitions? A) Code reusability B) Modularity C) Duplicate/Redundant data D) Efficient Code ANSWER:

C

Which of the following is not a feature of pure OOP? A) Classes must be used B) Inheritance C) Data may/may not be declared using object D) Functions Overloading ANSWER: ​

C

Which of the following is used for implementing inheritance through class? A) Inherited B) Using C) Extends D) Implements ANSWER:

C

Which of these can be overloaded? A) Methods B) Constructors C) All of the mentioned D) None of the mentioned ANSWER:

C

Which of these is correct way of inheriting class A by class B? A) class B + class A {} B) class B inherits class A {} C) class B extends A {} D) class B extends class A {} ANSWER:

C

Break statement is used to (i) get out of method ii) end a program iii) get out of a loop iv) get out of the system)? A) 1 & 2 B) 1,2 & 3 C) 1 & 3 D) 3 ANSWER:

D

How many classes can be defined in a single program? A) Only 1 B) Only 100 C) Only 1000 D) As many as you want ANSWER:

D

In which example will the loop display the numbers from 1 to 10? A) {int i = 0; while(i < 10) {System.out.println(i); i++;}} B) {int i = 1; while(i < 10) {System.out.println(i); i++;}} C) {int i = 0; while(i < = 10) {System.out.println(i); i++;}} D) {int i = 1; while(i < = 10) {System.out.println(i); i++;}} ANSWER:

D

The constructor of the Solution class is correctly declared in the variant? A) public Solution constructor() {} B) public Solution Solution() {} C) public static Solution {} D) public Solution() {} ANSWER:

D

The correct logical expression (for the Java language) is written as...? A) {(a < 3) Р (b < 3)} B) {(a < 3) and (b < 3)} C) {(a < 3) + (b < 3)} D) {(a < 3) && (b < 3)} ANSWER:

D

Which among the following best describes encapsulation? A) It is a way of combining various data members into a single unit B) It is a way of combining various member functions into a single unit C) It is a way of combining various data members and member functions into a single unit which can operate on any data D) It is a way of combining various data members and member functions that operate on those data members into a single unit ANSWER: ​

D

Which of these keywords can be used to prevent inheritance of a class? A) Super B) Constant C) Class D) Final ANSWER:

D

Which of these keywords must be used to handle the exception thrown by try block in some rational manner? A) Try B) Finally C) Throw D) Catch ANSWER:

D


Set pelajaran terkait

Chapter 7 part 1 (monosaccharides)

View Set

Romeo and Juliet: Identify literary devices, terms, rhyme patterns, Kind of dramatic speech can be found in these quotes.

View Set

Somatic Symptom and Dissociative Disorders

View Set

Chapter 8 Check your understanding

View Set

Business & Society Chapter: 16. Employees & Corporations

View Set

High Renaissance & Mannerism questions #1

View Set

THE CELLULAR BASIS OF INHERITANCE

View Set

chapt 6.2: classical conditioning

View Set