You are on page 1of 45

Q1.

Mary's teacher ask her to find, "s" comes under which type of variable from the below
code
class Sample
{
public void show()
{
System.out.println("Hello Java");
}
}
Class Mainclass
{
Public static void main(String ar[])
{
Sample s;
s =new Sample();
s.show();
}
}
Which of the following is true about "s"

"s" is an object

"s" is an instance variable

"S" is the object reference of Sample class

"s" is a local variable


Q2.
Steffy was assigned the job to create a class which cannot be inherited by other
classes. Select from the given option to help her
Final Class

Abstract Class

Inner Class

Static Class
Q3.
Jane was assigned the task to identify the invalid argument type for main() method
help him to complete the task.
String[] args
String args[]

String args

String[] ar
Q4.
Consider the following statement that represents a relationship: �Shyam has a best
friend who is a Tee�: Which of the following option represents the above relationship
correctly?
class Shyam { private Tee bestFriend; }

class Shyam implements Tee { }

class Shyam extends Tee { }

class Shyam { private BestFriend Tee; }


Q5.
Danny was assigned the job to create a module in XYZ project. As specified in the
requirement He supposed to create a class which should get the properties of class
Account. Find the process by which his class can acquire the property of the class
Account.
Polymorphism

Inheritance

Constructor

Dynamic Binding
Q6.
6) In Hotel Atlanta the expensive suit room is 203 The furniture in the suit room 203 is
very attractive Find the types of relationship incorporate in the above sentences
between suit room 203 and Hotel Atlanta,Suit room 203 and furniture Statement 1: Suit
room 203 and Hotel Atlanta Statement 2: Suit room 203 and furniture
Statement 1 is Inheritance and Statement 2 is Aggregation

Statement 1 is composition and Statement 2 is Aggregation

Statement 1 is composition and Statement 2 is inheritance

Statement 1 is Aggregation and Statement 2 is composition


Q7.
class Employee { private Employee () { } }
The above no-argument constructor, can be instantiated within the package

The above no-argument constructor, can be instantiated from the same

class

The above no-argument constructor, can be instantiated from any where


Q8.
Leela is new to java help her print the data in the function using the below option. class
Sample { ___? getName(String name) { return name.toUpper(); } } class Demo {public
static void main(String ar[]) { Sample s=new Sample();
System.out.println(s.getName(�Hexaware�)); } }
int

char

void

String
Q9.
class Child implements Account { int a=22; private void getAccountNo(int a) {
System.out.println(a); } } public class Puppy { public static void main(String []args){
Child c=new Child(); c.getAccountNo(12); } }
12

Private access specifier is not allowed in child class

22

private access specifier is not allowed in an Interface


Q10.
consider the following code: interface Payroll { public void getSalary(); } abstract class
Employee { public abstract void getSalary(); } Which of the following option gives the
correct implementation that uses the Payroll interface and Employee class?
public class Manager implements Payroll extends Employee { public void

getSalary() { /*do something*/ } }


public class Manager extends Payroll implements Employee public void

getSalary (){ /*do something*/ } public void Payroll.getSalary(){ /*do

something*/ } }

public class Manager implements Info extends Employee { public void

Employee.getSalary(){ /*do something*/ } public void getSalary (){ /*do

something*/
public }}
class Manager extends Employee implements Inter { public void

getSalary() { /*do something*/ } }


Q11.
Which of the following statement is true regarding access specifiers?
protected level access is only for members, not for classes

private level access is applicable for both classes and its members

public is applicable for local variables

package level access is only for members, not for classes


Q12.
7) In the below code what will be the output for �Name choosen is � and �Pupy�s
age is � public class Puppy { int puppyAge=6; String name="Danny"; public
Puppy(String name) { System.out.println("Name chosen is :" + name ); } public void
setAge( int age ) { puppyAge = age; } public int getAge( ) {
System.out.println("Puppy's age is :" + puppyAge ); return puppyAge; } public static
void main(String []args) { Puppy myPuppy = new Puppy( "tommy" ); myPuppy.setAge(
2 ); myPuppy.getAge( ); } } Predict the answer
tommy 2

Danny 6

Tommy 2

Danny 8
Q13.
Consider the following code: class Student { private String name; public Student() { }
public Student(String name) { this.name = name; this(); } } Which of the following
statement is true regarding the above code?
Compiles successfully without any error

Default constructors cannot be called from parameterized constructors

The this can be used only for accessing the member data and member

methods, not constructors

The this() call should be the first statement in the constructor


Q14.
Sam is working in DXY project and he is assigned the job to create a module in java.
The basic rules to create the classes in his module are: Others can use the class by
creating an object The class structure cannot be modified by others Identify the type of
class which Sam has to create
private

final

protected

static
Q15.
public class Test{ public static void main(String ar[]){ try{ return; } finally{
System.out.println("Finally"); } } } Select the correct answer from the given options
The program runs and prints nothing

The program runs and prints �Finally�

The code compiles, but an exception is thrown at runtime

The code will not compile because the catch block is missing
Q16.
public class Test{ int a//____insert code______________ void methodA(){ for(int
i=0;i<="" p="" style="box-sizing: border-box; box-shadow: black 0px 0px; margin:
0px; padding: 0px;">
int a[]={12,23,45,23};

int a=new int[5]);

int []a=new int[];


int a={12,23,45,23};
Q17.
Sam want to create a class in such a way it should prevent the overriding of the
methods.Help Sam to select the correct syntax from the given below choice?
final void methodA();

void final methodA();

static void methodA();

final abstract void methodA();


Q18.
Shiva is studying in an international school, it is one of the expensive school in the
town. Shiva is from a middle class family and his father is a carpenter, his parents
spend money to get him good education without showing the pain of earning. Map the
OOPS concept which was incorporate with the above scenario
class

Object

Inheritance

Abstraction
Q19.
Rita want to limit access to a method of a public class to members of the same class.
Which access modifier accomplishes this objective?
public

private

protected

Transient
Q20.
Anithi is from a small village and she went to her aunt�s house in town which is very
far from her house. In her aunt�s house she watched the Television programs she
learnt to operate the television .One day there was a problem with picture tube of the
television and she continuously switched on and switched off the Television without
knowing about the exact problem .The reason is she knows only to switch on,Off
,reduce and increase the volume of TV. Identify the type of oops concept incorporates
in the above case study
Class

Object

Inheritance

Abstraction
Q21.
abstract class Bike { abstract void run(); } class Honda ____________/* statement 1 */
{ void run() { System.out.println("running safely.."); } public static void main(String
args[]){ Bike obj = new Honda (); obj.run(); } } Choose and fill up the appropriate
code in the blank statement
implement Bike

implements Bike

extends Bike

extend Bike
Q22.
Ram ask his Team member �Reta� to create a class which should have accesss to
members of another class in the same package.Which is the most restrictive access
modifier that will accomplish that will accomplish this objective?
public

private

protected

default
Q23.
Which of the following option gives the name of the Exception which is thrown when a
String with Non-Numeric value is parsed with Integer.valueOf() method?
NumberFormatException

IllegalArgumentException

ParseException

ArithmeticException
Q24.
Consider the following listed items: A. Employee() { } B. public Employee() { } C.
private Employee() { } Consider the following statements: I. no-argument constructor,
that does not allow instantiation from within the package II. no-argument constructor,
that does not allow instantiation from outside the package III. no-argument constructor
Which of the following option gives the exact matches of above listed items and
statements?"
A-II, B-III, C-I

A-III, B-I, C-II

A-I, B-II, C-III

A-II, B-I, C-III


Q25.
public class Internet { private int y = 8; public static void main(String[] args) { new
Internet().go(); } void go() { int x = 7; TCPIP ip = new TCPIP(); class TCPIP { void
doit() { System.out.println(y + x); } } ip.doit(); } } Select the correct option:
Compilation succeeds.

Compilation Failed

Throws Exception

Runtime Error
Q26.
What will happen if run the following code? class Q2 { public static void main(String
ar[]) { Boolean[] b1 = new Boolean[10]; boolean[] b2 = new boolean[10];
System.out.println("The value of b1[1] = " +b1[1]); System.out.println("The value of
b2[1] = " +b2[1]); } }
Prints "The value of b1[1] = false" "The value of b2[1] = false".

Prints "The value of b1[1] = null" "The value of b2[1] = null".

Prints "The value of b1[1] = null" "The value of b2[1] = false".

Prints "The value of b1[1] = false" "The value of b2[1] = null".


Q27.
class Test { static void show() { System.out.println("Show method in Test class"); } }
public class Q2 extends Test { static void show() { System.out.println("Show method in
Q2 class"); } public static void main(String[] args) { Test t = new Test(); t.show(); Q2 q
= new Q2(); q.show(); t = q; t.show(); q = t; q.show(); } }
prints "Show method in Test class" "Show method in Q2 class" "Show

method in Q2 class" "Show method in Q2 class"

prints "Show method in Test class" "Show method in Q2 class" "Show

method in Test class" "Show method in Test class"

prints "Show method in Test class" "Show method in Q2 class" "Show

method in Test class" "Show method in Q2 class"

Compilation error.
Q28.
48) Consider the following code snippet: Integer i=1411, j=i; System.out.println(i++);
System.out.println(++j); Which of the following option gives the correct number of
Auto-boxing and Auto-Unboxing occurred in the above code?
Auto-boxing: 4, Auto-Unboxing: 3

Auto-boxing: 3, Auto-Unboxing: 2

Auto-boxing: 1, Auto-Unboxing: 0

Auto-boxing: 2, Auto-Unboxing: 0
Q29.
Consider the following code: public class TestOverloading { int length(String s) { return
s.length(); } float _length(String s) { return (float) s.length(); } } Which of the following
statement is true regarding the above code?
Both the length() methods are duplicated methods

Both the length() methods are overloaded methods

Overloaded methods should be declared as public

Both the length() methods are Overriding methods


Q30.
Consider the following code: class Student { private String name; public Student() { }
public Student(String name) { this.name = name; this(); } } Which of the following
statement is true regarding the above code?
The this() call should be the first statement in the constructor
Compiles successfully without any error

Default constructors cannot be called from parameterized constructors

The this can be used only for accessing the member data and member

methods, not constructors


Q31.
public class Bunnies { static int count = 0; Bunnies() { while(count < 10) new
Bunnies(++count); } Bunnies(int x) { super(); } public static void main(String[] args) {
new Bunnies(); new Bunnies(count); System.out.println(count++); } } Select the
Option:
9

10

11

Compilation fails
Q32.
47) Consider the following statement that represents a relationship: �Shyam has a
best friend who is a Tree�: Which of the following option represents the above
relationship correctly?
class Shyam implements Tree { }

class Shyam { private BestFriend Tree; }

class Shyam extends Tree { }

class Shyam { private Tree bestFriend; }


Q33.
public class Kant extends Philosopher { // insert code here public static void
main(String[] args) { new Kant("Homer"); new Kant(); } } class Philosopher {
Philosopher(String s) { System.out.print(s + " "); } } Select the correct option
Kant() { this("Bart"); } Kant(String s) { super(s); }

Kant() { super(); } Kant(String s) { super(s); }

Kant() { super("Bart","KRR"); } Kant(String s) { this(); }

Kant() { super("Bart"); } Kant(String s) { this("Homer"); }


Q34.
class IcelandicHorse { void tolt() { System.out.print("4-beat "); } } Select the correct
option: public class Vafi extends IcelandicHorse { public static void main(String[] args) {
new Vafi().go(); new IcelandicHorse().tolt(); } void go() { IcelandicHorse h1 = new
Vafi(); h1.tolt(); Vafi v = (Vafi) h1; v.tolt(); } void tolt() { System.out.print("pacey "); }
}
4-beat pacey pacey

pacey pacey 4-beat

4-beat 4-beat 4-beat

4-beat pacey 4-beat


Q35.

In the above picture we can see Tourists are enjoying the thrill ride. If a person should
ride in the thrill rider mandate to have the seat locks. Map the above scenario with
exception handling concept and select the correct option.
Unchecked Exception

Checked Exception

Error

None of the above


Q36.
___________is a level of the software testing process where individual components of a
software/system are tested.
integration

system

unit

module
Q37.
what are some characteristics of a good test
can be run in any order

consistently returns the same result


all of the above

none of the above


Q38.
what is test coverage
It�is a detailed document that describes the test strategy, objectives,

schedule, estimation

It is defined as a metric in Software Testing that measures the

amount of testing performed by a set of test.

�defined as any functionality that can be tested.�

it is defined as type of software testing to confirm that a recent program or

code change has not adversely affected existing features.


Q39.
Identify the testing frameworks available for Java
Jtest

TestNG

Cactus

all of the above


Q40.
Which of the following annotation causes that method run once before any of the test
methods in the class?
@Test

@Before

@BeforeClass

@AfterClass
Q41.
Which statements below are true about Junit
It is a open source testing framework
Runs a bunch of tests and reports their results

it�s a regression testing framework

all of the above


Q42.
What is the use of @After
It is invoked everytime after test class

it is invoked everytime after test method

it is invoked everytime after test suite

it is used to invoke a test


Q43.
what is the purpose of void assertTrue(boolean condition)
functionality is to check that a condition is true

functionality is to check that the two objects refer to the same object.

functionality is to check that the two objects do not refer to the same

object.

functionality is to check that a condition is true


Q44.
Features of Junit
Assertions

Test Fixture

Annotation

all of the above


Q45.
___________ are used to benchmark software components repeatedly. Their purpose is
to ensure that the code under test runs fast enough even if it�s under high load
integration

unit test
performance

load
Q46.
Identify valid test case
@Test public void testPrintMessage(){

assertEquals(message,printmessage()); ]
@BeforeTest public void testPrintMessage(){

assertEquals(message,printmessage()); ]
@SampleTest public void testPrintMessage(){

assertEquals(message,printmessage()); ]
@Test public int testPrintMessage(){

assertEquals(message,printmessage()); ]
Q47.
Pointers you should consider while creating a test method
Test method must not throw any exception

test method must not have any parameters

all of the above

none of the above


Q48.
which package should you import while using Junit
junit

unit.framework

framework

junit.framework
Q49.
What should be the return type of a test method
Object

Object[]
void

int
Q50.
What is the correct order of execution 1.Test 2.BeforeClass 3.AfterClass 4.Before 5.After
24153

12345

54321

32451
7/20/22, 1:09 PM Hexaware

Result & Analysis


Student: Bala Vamsi Pe Email id: balavamsi.7@ Test: SFTT_AS_MCQ_PrCourse: 2022 - Hexawa

Attempt 1

IP Address: 202.21.42.138 Tab switches: 0 OS used: Windows Browser used: Chrome

Test Duration: 00:07:40 Test Start Time: Jul 4, 2022 | 08:31 PM


Test Submit Time: Jul 4, 2022 | 08:40 PM

Overall score MCQ

Rank: NA Rank: NA

8 Topper score: 10.00 / 10 8 Topper score: 10.00


/ 10

/ 10 Average score: 6.76 / 10 / 10 Average score: 6.77


/ 10

Least score: 0.00 / 10 Least score: 0.00


/ 10

Overall Question Status MCQ - Question Status

Total Questions: 10 Total Questions: 10

Questions Attempted: 10 Questions Attempted: 10

10 Questions Correct: 8 10 Questions Correct: 8

/ 10 Question Wrong: 2 / 10 Question Wrong: 2


Partially Correct: 0 Partially Correct: 0

Question Not Viewed: 0 Question Not Viewed: 0

Topic wise Analysis MCQ 

Question No: 1 Multi Choice Type Question Report Error

A class inherits an interface using which keyword?

Extends

Implements CORRECT

Inherit
https://eiphexaware.examly.io/result?testId=U2FsdGVkX1%2F8NyscSNN%2FpN%2FadqpaOD9V2jrZ0iinsMXzNG3Xrv8etX1SWSZip6yx 1/8
7/20/22, 1:09 PM Hexaware

None

Status: Correct Mark obtained: 1/1 Hints used: 0 Level: Medium


Question type: MCQ Single Correct Subject: Programming
Subject: Java Programming Subject: Inheritance

Question No: 2 Multi Choice Type Question Report Error

What is the output of this program?


1 class X  
2 {
3 int a;
4 double b;
5 }
6 class Y extends X
7 {
8 int c;
9 }
10 class Output
11 {
12 public static void main(String args[])
13 {
14 X a = new X();
15 Y b = new Y();
16 Class obj;

true

false CORRECT

Recommended Learning Content: this keyword in Java Access Modifiers in Java


Classes and Objects OOPS Concepts in Java Super keyword in Java
Learn Constructors in Java

Status: Wrong Mark obtained: 0/1 Hints used: 0 Level: Medium


Question type: MCQ Single Correct Subject: Programming

https://eiphexaware.examly.io/result?testId=U2FsdGVkX1%2F8NyscSNN%2FpN%2FadqpaOD9V2jrZ0iinsMXzNG3Xrv8etX1SWSZip6yx 2/8
7/20/22, 1:09 PM Hexaware

Subject: Java Programming Subject: Classes and Objects

Question No: 3 Multi Choice Type Question Report Error

What will be the output for the following code snippet?


1 Hashtable obj = new Hashtable();
2 obj.put(2,"A");
3 obj.put(null,"B");
4 obj.put(null,null);
5 System.out.println(obj.size());
6 System.out.println(obj);
7

[2=A, null=B]

Run time Exception CORRECT

CompileTime Exception

[2=A, null=null]

Recommended Learning Content: Generics and Collections

Status: Correct Mark obtained: 1/1 Hints used: 0 Level: Easy


Question type: MCQ Single Correct Subject: Programming
Subject: Java Programming Subject: Collections

Question No: 4 Multi Choice Type Question Report Error

What will be the time complexity to perform contains() operation in Lists?

O(n) CORRECT

https://eiphexaware.examly.io/result?testId=U2FsdGVkX1%2F8NyscSNN%2FpN%2FadqpaOD9V2jrZ0iinsMXzNG3Xrv8etX1SWSZip6yx 3/8
7/20/22, 1:09 PM Hexaware

O(n*n)

O(1)

Can't be determined

Recommended Learning Content: Generics and Collections

Status: Correct Mark obtained: 1/1 Hints used: 0 Level: Easy


Question type: MCQ Single Correct Subject: Programming
Subject: Java Programming Subject: Collections

Question No: 5 Multi Choice Type Question Report Error

Given the following code snippet, what is the value of movieRating after it is executed? 
1 int characters = 5;
2 int story = 3;
3 double movieRating = characters <= 4 ? 3 : story>1 ? 2 : 1;

2.0 CORRECT

3.0

The code doesn't compile

Exception

Status: Wrong Mark obtained: 0/1 Hints used: 0 Level: Medium

https://eiphexaware.examly.io/result?testId=U2FsdGVkX1%2F8NyscSNN%2FpN%2FadqpaOD9V2jrZ0iinsMXzNG3Xrv8etX1SWSZip6yx 4/8
7/20/22, 1:09 PM Hexaware

Question type: MCQ Single Correct Subject: Programming


Subject: Java Programming Subject: Operators and Expressions

Question No: 6 Multi Choice Type Question Report Error

Which two operators would be used to test if a number is equal to or greater than 5.21 but
strictly less than 8.1? 

> and <= 

>= and > 

< and >=  CORRECT

< and > 

Status: Correct Mark obtained: 1/1 Hints used: 0 Level: Medium


Question type: MCQ Single Correct Subject: Programming
Subject: Java Programming Subject: Operators and Expressions

Question No: 7 Multi Choice Type Question Report Error

What is the output of the following application?


1 package game;  
2 public class Football {
3 public static void main(String officials[]) {
4 try {
5 System.out.print('A');
6 throw new RuntimeException("Out of bounds!");
7 }
8 catch (ArrayIndexOutOfBoundsException aioobe) {
9 System.out.print('B');
10 throw t;
11 }
12 finally {
13 System.out.print('C');
14 }
15 }
16

ABC

https://eiphexaware.examly.io/result?testId=U2FsdGVkX1%2F8NyscSNN%2FpN%2FadqpaOD9V2jrZ0iinsMXzNG3Xrv8etX1SWSZip6yx 5/8
7/20/22, 1:09 PM Hexaware

ABC, followed by a stack trace for a


RuntimeException 

AC, followed by a stack trace


CORRECT
for a RuntimeException 

None of the above 

Recommended Learning Content: Exception Handling (Try and Catch)


Exception Handling (Try with multiple catch checked)
Exception Handling (Try with multiple catch unchecked) Exceptions
Exception Handling (Finally)

Status: Correct Mark obtained: 1/1 Hints used: 0 Level: Medium


Question type: MCQ Single Correct Subject: Programming
Subject: Java Programming Subject: Exceptions

Question No: 8 Multi Choice Type Question Report Error

If a try statement has catch blocks for both Exception and IOException, then which of the
following statements is correct? 

The catch block for Exception must


appear before the catch block for
IOException. 

The catch block for


IOException must appear
CORRECT
before the catch block for
Exception. 

The catch blocks for these two


exception types can be declared in any
order. 

A try statement cannot be declared with


these two catch block types because
they are incompatible. 

Recommended Learning Content: Exception Handling (Try and Catch)


Exception Handling (Try with multiple catch checked)

https://eiphexaware.examly.io/result?testId=U2FsdGVkX1%2F8NyscSNN%2FpN%2FadqpaOD9V2jrZ0iinsMXzNG3Xrv8etX1SWSZip6yx 6/8
7/20/22, 1:09 PM Hexaware

Exception Handling (Try with multiple catch unchecked) Exceptions


Exception Handling (Finally)

Status: Correct Mark obtained: 1/1 Hints used: 0 Level: Medium


Question type: MCQ Single Correct Subject: Programming
Subject: Java Programming Subject: Exceptions

Question No: 9 Multi Choice Type Question Report Error

 Which method compares the given object to this object?

public boolean equals(Object


CORRECT
obj)

public final void notifyAll()

public final void notify()

public final ClassgetClass()

Status: Correct Mark obtained: 1/1 Hints used: 0 Level: Medium


Question type: MCQ Single Correct Subject: Programming
Subject: Java Programming Subject: Objects

Question No: 10 Multi Choice Type Question Report Error

 If there are 5 classes, E is derived from D, D from C, C from B and B from A. Which class
constructor will be called first if the object of E or D is created?

A CORRECT

A and B

https://eiphexaware.examly.io/result?testId=U2FsdGVkX1%2F8NyscSNN%2FpN%2FadqpaOD9V2jrZ0iinsMXzNG3Xrv8etX1SWSZip6yx 7/8
7/20/22, 1:09 PM Hexaware

Recommended Learning Content: this keyword in Java Access Modifiers in Java


Classes and Objects OOPS Concepts in Java Super keyword in Java
Learn Constructors in Java

Status: Correct Mark obtained: 1/1 Hints used: 0 Level: Medium


Question type: MCQ Single Correct Subject: Programming
Subject: Java Programming Subject: Classes and Objects

https://eiphexaware.examly.io/result?testId=U2FsdGVkX1%2F8NyscSNN%2FpN%2FadqpaOD9V2jrZ0iinsMXzNG3Xrv8etX1SWSZip6yx 8/8

You might also like