Objectives
Objectives
Objectives
Table of Contents
Sections: ......................................................................................................................................................... 2
Patterns:..................................................................................................................................................... 2
Collections:................................................................................................................................................. 3
Coding Standards: ...................................................................................................................................... 3
String Literals: ............................................................................................................................................ 4
Final:........................................................................................................................................................... 4
Enum: ......................................................................................................................................................... 5
Abstract Class: ............................................................................................................................................ 5
Interface: .................................................................................................................................................... 6
Vargs: ......................................................................................................................................................... 6
Inheritance: ................................................................................................................................................ 7
Type Conversion: ....................................................................................................................................... 7
Loops: ......................................................................................................................................................... 7
Constructors: ............................................................................................................................................. 7
Packages: ................................................................................................................................................... 8
Super: ......................................................................................................................................................... 8
Lambda: ..................................................................................................................................................... 8
Exception Handling: ................................................................................................................................... 9
Sections:
Patterns:
1) Which of the below statement indicate the need to use of Factory pattern?
d) when we want to allows the sub-classes to choose the type of objects to create
Answer : D
2) Which among the following is/are true about the design pattern? Select any two option
b) Design patterns are completed designs that can be transformed directly into code.
d) Design pattern is a template of solving problem that can be used in many real world software
development problems.
Answer: A & B.
63) Which of the following pattern refers to creating duplicate object while keeping performance in
mind?
Ans: Option C
Collections:
1) which of the following statements are true if a duplicate element objT is added to a Hashset?
a) The element objT is not added and add() method returns false.
Answer: a
A. Boolean
B. int
C. Byte
D. Character
Answer : D
47.Which among the following option are correct with respect to HashMap?
Answer : C
Coding Standards:
1) Which of the below code is implemented without best practice standard
System.out.println(itr.next);}
System.out.println(i1==i2)
a) Option(i) doesn’t follow best practices can be improved using for (String S: strList)
b) Option(ii) doesn’t follow best practices as objects should not be compared with ==
c) Option(i) and (ii) are not following best practices.
d) Option(i) and (ii) are following best practices.
Answer : C
a) METHOD_NAME
b) MethodName
c) methodName
d) Method_Name
Answer : C
String Literals:
9) Which of the below are not good practice for creating objects?
Ans : B
Final:
1) Which of the following keyword is used to prevent the content of a variable from being modified from
outside?
a) final
b) constant
c) static
d) transient
Answer : a
Enum:
17)Which of the following are true about enums in java?(Choose any 3)
Answer : a , c , d
Abstract Class:
19) Which of the following statement regarding an abstract class are true in java?
ii) An abstract class is designed only to act as a base class in hierarchy to be inherited by other classes.
a) Only i
b) Only ii
c) Both I and ii
d) Neither I and ii
Answer : B
35) which of the following mechanism in OOP is a process of hiding certain details and showing only
essential information to the user?
a) Polymorphism
b) Encapsulation
c)Abstraction
d)Inheritance
Answer : C
62) If the Child class of an abstract class does not implement all its abstract methods then it should be
declared as?
Option D: Interface
Ans: Option A
Interface:
1) which of the following interface should be implemented by a resource, if we want to create the object
of that resource in the resource part of a try block?
a) Closeable
b)Closeable<E>
c)AutoCloseable
d)AutoCloseable<E>
Answer : C
Vargs:
48. How many numbers of values can be accommodated by Varargs in Java?
Answer: D
A.First place
B.Last Place
D.Can be anywhere
Ans : B
Inheritance:
49. Which of the following keyword can be used to restrict a class to be inherited in Java?
A.Abstract
B.final
C.constant
D.private
Answer : D B
Type Conversion:
52) Which of the following is a necessary condition for implicit type conversion in Java?
Option C: The destination type can be larger or smaller than source type
Option D: The destination and the source type are the same.
Ans: Option B
Loops:
54) Which of the following Jump statement can skip processing of one iteration if a specified condition
occurs and remaining iterations?
Option A: break
Option B: return
Option C: continue
Option D: exit
Ans: Option C
Constructors:
55) Which of the following is false regarding parameterized constructors in Java?
A.First statement
B.Last Statement
Ans : A C
Packages:
56) Ria has a class called ‘Account.java’ under tow separate packages com.infy.debit and com.infy.credit.
Can she use the Account class of both the packages in another class called ‘ReportUti.java’ of package
com.infy.util?
Option B: No, she cannot as there will be a compliation eror stating the import collides with another
import
Option C: No, she cannot. The code will pass compilation but an ambiguity will get encountered during
the execution.
Option D: No, she cannot as there will be a compilation error whiel creating Account class for the second
time through in a different
Ans: Option B
Super:
72. Which of the following Java component can’t be referred using ‘super’ keyword?
A.public contructor
B.protected method
C.private method
Ans : C
Lambda:
76. Which of the following is a valid lambda expression?
A.(sum) → true
B.x,y → true
A,C,D
Exception Handling:
73. Which of the following are the advantage of exception handling in Java(choose any 3 option)?
Ans : A,B,D