Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
12 kB
4
Indexable
2. What is the correct way to create an object called myObj of MyClass?
c. MyClass myObj = new MyClass();

3. OOP promotes a way of programming that allows programmer to think in terms of ___
d. Objects

4. Constructor are used to ___
c. Initialize a new object

7. The process by which one object can acquire the properties of another object
c. Inheritance

10. Which of the following is used to make an Abstract class?
a. Making atleast one member function as pure virtual as pure virtual function

11. What modifiers are allowed for methods in an Interface?
a. public

12. Which of the following is/are true about packages in Java?
a. 1,2 and 3
{
1) Every class is part of some package.
2) All classes in a file are part of the same package.
3) If no package is specified, the classes in the file go into a special unnamed package.
}

13. Which of the following is/are advantages of packages?
a. Packages avoid name clashes

16. java.util.Collections ia a ___
a. Class

17. Which of those allows duplicate elements?
b. List

18. What class does readLine() belong to?
d. BuffereReader

19. What stream type provides input from a disk file?
a. FileReader

23. Which statement is true about a static nested class?
b. It does not have access to nonststic members of the enclosing class

24. Which members of a class cannot inherit in its subclass?
a. Contructor
b. private member

25. Which statement is false for non-static nested class?
d. Non-Static nested class can not access directly object members in outer class but can access through object.

26. An interface cannot consist of 
a. abstract method with abstract keyword

28. Which is false about abstract classes?
d. Abstract classes can be used to create objects

29. Which declarations are false foe interface or inheritance? Where A, B, C are classes, IA, IB, IC are interfaces
b. class A extends B, C{}
d. class B extends IB{}

30. Which of the following is true about methods in an interface in java?
b. We can define a default and static method in an interface
d. An interface can contain class constants, implied as final and static

31. Which option is true for abstract class?
a. A non-abstract subclass of an abstract class must define all abstract methods of super class

32. Consider the following two statements Integer x = 25; Integer y = new Integer(33); Which of the following statements is true
b. Statement 1 uses autoboxing

33. Assume a method contains code which may raise an runtime exception. What is the correct way for that method to declare it does not handle that exception?
d. Don't need to specify anything

34. Which option is correct about runtime exception?
b. Runtime exception is checked at runtime
d. If runtime exception is not handled(try...catch or throws), code is compiled with no error

35. What algorithm quickly searches an ordered array?
a. Binary search

36. The Book class implements the Comparable<Book> interface. What method must class Book contain?
a. int compareTo(Book other)

38. Which of these class is not a member class of java.io package?
a. String

39. How to detect end of an ObjectInputStreamf?
a. throw EOFException object

1. Which option is true for OOP's characteristics?
b. Encapsulation is combining data field and behavior in one class
c. Abstraction is the process of exposing the essential details of an entity, while ignoring the irrelevant detils, to reduce the complexity for the users

5. What kind of variables a class can consist of?
b. Member variables, Local variables, Parameters
d. Class variables, Local variables, Instance variables, Parameters

6. What are true for "static" keyword in Java?
a. We can have static block in a class.
c. We can have static method implementation of an interface

9. In Java, when we implemenet an interface method, it must be declared as:
c. public

11. Which of the following concept is often expressed by the phrase 'One interface, multiple methods'?
b. Polymorphism

12. What restriction is there on using the super(..) reference in a constructor?
d. It must be used in the first statement of the constructor.

15. Which of the following is true about methods in an interface in Java?
b. We can define a default and static method in an interface
d. An interface can contain class constants, implied as final and static

17. Consider the following two statements Integer x = 25; Integer y = new Integer(33); Which of the following statements is true:
b. Statements 1 uses boxing

18. You have the following code: String s = "Hello"; String t = " " + "my" + " "; s.concat(t); s.toLowerCase(); s += "friend"; System.out.println(s); what will the output be?
d. Hellofriend

20. Which option is true for abstract class?
a. A non-abstract subclass of an abstract class must define all abstract methods of super class

1. What is true about keywords throw and throws?
b. throw is followes by instance, throws is followed by class

1. Assume a method contains code which may raise an runtime exception. What is the correct way for that method to declare is does not handle that axception?
d. Don't need to specify anything

1. Which option is correct about runtime exception?
b. Runtime exceptions is checkes at runtime
d. If runtime exception is not handled (try ... catch or throws), code is compiled with no error

1. Which option is not uses to acces a public package member from outside its package?
a, Refer the member ny its name

1. Which collection is not threadsafe, and allows to access its elements by index?
b. ArratList

1. Which modofifier should be used to indicate that a data member should not be part of the serialization process?
c. transient

1. What mathod of Collections class is used to search for a specified element in a sorted list?
d. binarySearch

1. How to detect end of ObjectInputStream?
a. throw

1. Deserialization is ___?
a. the reverse process where the byte stream is used to recreate the actual Java object in memory.
d. the process of reading an object

1. The FIle class does not contain any method for ___
c. Reading and writing single or multiple bytes

1. A Java object is serializable if its class or any of its superclasses implements interface ____
a. Serializable

1. What is the output of the following code? import java.util.*; 
class A{
public static void main(String[] args){
TreeSet<String>
set=new TreeSet<>();
set.add("A");
set.add("E");
set.add("B");
set.add("D");
set.add(null);
System.out.println(set);
}
}
a. NullPointerException

1. Each tree based collection assunes its elements to be of ___ type?
b. Comparable

1. What type of collection would we use if we wanted no duplicates?
d. Set

1. The following code snippet <T extneds Number> is an example of ___?
a. bounded type

1. Which List would you use if want to do lost of insertions and deletions?
b. LinkedList

1. Given the following code, f is called:
File f = new
File("src/file/ReadTextFile.java");
a. Abstract pathname

1. The method with the same name or different return type and difference in the parameters either in number or type is known as
b. Compile Time Overloading

2. To call a base class constructor in a derives class, is it needed to call base class initializer.
b. False

3. Can objects of abstract classes be instantiated?
b. False

4. The process by which one object can acquier the properties of another object
b. Inheritance

5. Constructors are used to
c. Initialize a newly created object

6. An object that has more than one form is referred to as
d. Polymorphism

7. Information Hiding can also be termed as
b. Encapsulation

8. Pick the term that relates to polymorphism
a. Dynamic binding

9. Main method can be overriden
b. False

10. The keyword which is used to access the methos or member variables from the superclass
a. Super

11. What modifiers are allowed for methods in an Interface? (choose one or more answers)
a. Public
c. Abstract

12. When sub class declares a method that has the same tyoe of arguments as a method declared by one of its superslasses, it is termed as
a. Method overriding

1. Which OPPS concept means exposing only necessary information to the calling functions?
a. Encapsualtion

2. In which method changes made to the parameter inside the function have no effect on the argument?
a. Call by Value

3. Which of the following type of class only a single instance of itselt to be created?
a. Singleton class

4. Which oops concept is used as reuse mechanism?
c. Inheritance

5. Which function of a class is defined outside that class' scope but it has the right to access all private and protected members of the class?
c. Friend function

6. Which constructor creates a new object of the same class using an existing object?
a. Copy constructor

7. Which constructor has no paramrters?
d. Default Constructor

8. Which class is the most generalized class and the parent class of a derived class?
d. Base class

9. Which class is a class that inherits a method or methods from a superclass?
a. Sub class

10. How many instances can be created for an abstract class?
a. 0

11. Do ew require parameter for constructors?
a. No

12. Which of the following is not a type of constructor?
b. Friend construction

13. Which is also known as late binding or run-time binding?
c. Dynamic binding

14. Which of the following statements is correct?
b. Derived class pointer cannot point to base class

16. Which of the following is a value provided in function declaration that is automatically assigned by the compiler if caller of the function doesn't provide a value for the argument with default value?
c. Default arguments

17. In which of the following concepts the function calls are not resolved until runtime and they are not bound until runtime?
c. Dynamic binding

18. Which of the following is a normal function but it can only called by using an object rather a normal function that can be called directly?
b. Member function

19. How many instances of an abstract class can be created?
a. 0

20. Which of the following is not the member of class?
b. Friend function

21. Which of the following can be friend?
d. a and b

22. Which of the following concepts of OOPS means exposing only necessary information to client?
c. Data hiding

23. Dynamic loading means adding new components to a program as it runs.
a. Yes

24. Why rederence is not same as a pointer?
d. All if the above

25. Which of the following concepts provides favility of using object of one class inside another class?
c. Composition

26. How many types of polymorphisms are supported by C++?
b. 2

27. Which of the following statement is correct about a constructor?
e. a and c

28. Function overloading increases the readability of the program because
a. you don't need to use different names for same action

29. Which of the following concepts of OOPS means wrapping data (variables) and code together as a single unit?
a. Encapsulation

30. Which of the following is correct about function overloading?
d. Both a and b

31. Which of the following concepts means that the code to be executed for a specific procedure call is not known until run-time?
a. Dynamic binding

32. The purpose of constructor is to ___
b. initialize the object of a class

33. Is an exception a runtime error?
a. Yes

34. Late Binding in C++ can be achieved using
d. Virtual function

35. Reusability is a desirable feature of a language because it ___
d. Both a and b

36. Which of the following is an example of static polymorphism?
d. a and c

37. Which of the following concepts means wrapping the data variables and code acting on the methods together as a single unit?
a. Encaosulation

38. Choose the correct statements regarding inline functions
d. Both a and b

39. Which of the following is correct about class and structure?
c. class data members are private by default while that of structure are public by default