IINTIEGRAIED-
MOCK- onsiden the below code
OBJ 21Dec20- Class ester
Section
publicstaticvoid mainStnng argsl
Queue inIntQueue1new Queue(3)
Queue nntQueue2 new Queue)
fordnt counter1-0counter12,counter1+
4
inlntQueue1.engueuelcounter1 3
5 torintcOunter20ounter 2:counter2++)
fcounter2
break
ninteueuezengueueinlntaueueT.dequeus You're being p
9 10 nintQueueg.engueue12
IINIEUkAIED
MOCK System.out.printlninlntQueue2 elements are."
in IntQueue2.display0
OBJ 21Dec20-
Section
Assumption: Al the references to the necessary files are available
What is the status of inlntQueuel and inlntQueue2 after the exeaution ofthe above code?
n the options,consider the elements of the queue from Front to Rear
You're being pra
OinlntQueue1:0, 3,6 and inlntQueue2: 0,3, 12
10
inlntQueue1 6 and inlntQueue2: 0, 3
11 12
inlntQueue1: 6 and inlntQueue2: 0, 3, 12
2 markS
What is the output ofthe codegiven below?
Class Demo
private staticint var1=40
final int var3 4 0
private int var2 4 0
public Demoint var2)
this.var2 var2
this.var2 +this.var2-var3
Demovarl= Demo.var1
Demo.var1
publicint method10
return Demo.var1+this.var2
public static void main(String args
Demo.var1-
Demo obj1= new Demo(40
Demo obj2 = new Demo@0))
System.outprintin(obj1.method 10+obj2.nmethod10%
INIEGRAIED
MOCK Demo obj2 =
new Demo(30;
OBJ 21Dec20- System.out.println(obj1.method10+obj2.method10
Section
O66
O 70
64
O76 YO
Reset Save
12
ITNIEGRAIEU
MOCK-
OBJ 21Dec20- 12marks]
Section What is the output of the code
given below?
2 Dublicdass lester
public staticvoid main(string argsiE
String temp Str "ltsAVerySimpleProblem"
=
3 empStr=tempstr.tol
tolowerCase(:
Strng tempnetempstr subst temp Strlength0-2
Stringfinalvalue =
int index1 3 =
iftempCne.substring(tempOne.length0-1).equals"e")l
forint counter1 0:counter1 <tempOnelength0-5 counter1+
finalvalue+tempOne.substring(counter1-6):
YOE
10 elsel
finalValue += tempOne.substingindex1-2
11 12
System.outprintln(finalValue)
IN IEGRAIED
MOCK-
OBJ 21Dec20- else
Section finalValue + tempOne.substringindex1-2)
System.out printlnfinalValue
5 6
O Avery
Verysimple
Yo
Overysimpleprobl
10
O Simple
11
INIEGRAIEU-
MOCK-
OBJ 21Dec20- B marks
Section
What is the output of the code given below?
dass Demol
public static void main(string argsl
Demoobj-new Demo0,
4 ystem.out.println(obj.test4, "Sam")
blic string testint num stng name
5
if(num= 01
etumahamie
else ittname equalsiname23
numnum +1, You
return testinum. name)
9
elsel
12 name=name + numn
11 num num -1
=
return test(num, name
IINIERKAIDL
MOCK elsel
OBJ 21Dec20- hame name num,
Section num num 1
retum test(num, name
2
Sam4321
OSam434321
OSam
10
4321Sam
IINIEGRKAIED
MOCK- marks
OBJ 21Dec20- Examine the following code What iS the temm ror
Section converting the wrapper dass back to a p
public static void main String args
tege price new nteger34
3 int finalPrice pr
OAutoboxing You're
10 Onboxng
ype casting
BJECIVE JESTIONS
IINIEGRAIEU-
MOCK- How many reference variables and objects will be created
by the below code?
OBJ 21Dec20- cdass Demof
Section public static void main(String argsl)
Demo obj1=new Demo0
Demo obj2=obj1
obj2=new Demo0
Demo obj3obj2
obj2=obj3
new Demo0.display0
woid displayol
stem.cutpantn Disp
You're b
10 2 reference variables and 3 objects
12 reference variablesand 3 objects
INIEGKAIEU-
MOCK- 2 marksl
OBJ 21Dec20-
Section Given the following linked list
linkedList(Head to Tail):1-54-s6-7-59
What would be the state of the linkedList after the
below code is executed wrhen the head node of the
inkeduist and num5 are passed as input to the
arrangeElements) method?
public dass Testerl
4 public static void mainstring argsu
Tester oDi-new Tester0
LinkedListlinkedList=new Linkedlist@
linkedlistaddAtEnd1)
linkedList
addAtEnd4
8
linkedlist.addAtEnd(6
linkeduist.
addAtEnd7)
nkedist.addAtEnd(9) Youre being pro
10 10 obj.arrangeElementslinkedlistgetHead0.5
linkedlist.display0
2 public vld arangeElements(Node head.int num)
Node temp head
int index temp1,val
IINIEURATEU
MOCK public void
OBJ 21Dec20- Node temp head
arrangeElements(Node head.int num)
Section int indextemp 1,val;
ifthead==null
return
index=1
whileindex <num
val =
temp.get Data0
temp =temp.getNext0:
head.setData(val);
index + 1
temp1 = head.getData0:
You're
temp.set Data (temp1)
Assumption All the references to the necessary hes are
avalable Method getNext0 retu
INIEGKAIEU-
MOCK-
OB 21Dec20- Assumption: All the references to the necessary files are
Method getData) returns data of the available. Method
Section node getNext) returns the
Note lements in options are shown
from Head to lail.
O746.79
O14.6.7.7
O746.77
O14679
Youire bein
10
Reset Save
2
IINIEGRAIED
MOCK- [1 marks]
OB) 21Dec20- What is the time
Section complexity of the code given below?
public void display(nt num)
forfint counter1 0 cOunter1 <num; counter1++)
forint counter2=0; counter2 <num;
counter2++)
System.out.printint"success")
Onn2)
You're being
O Olog n)
10
12
OOnlogm
INIEGRAIED
MOCK- Mmarks]
OBI 21Dec20- Number 14 needs to be seardhed
Section using BINARY SEARCHin the following
1,3, 7,9, 14, 19, 45 sorted aray of numbers
How many comparisons will be required to condude that the
Note: The index starts with 0 (zero) number 14 is found in the 5th position=
3
You're being
4
O
IINIEUKAIEL
MOCK- dass ClassX {
OBI 21Dec20- Private int val
Section
public ClassXint valt
this.val=val,
public int method10
return this.val/2
dass ClasSAI
Protected static int counter 0
private int num1:
public ClassA(int val1)
ClassA.counter +=1; You're being
this.num1 = val1;
10
publicint method201
this.num1=3,
return this.num1
EDIION
IINIEGRAIED-
public int method201
MOCK
OBJ 21Dec20- this.num1=3;
Section returm this.num1
Publicint getNum10
return this.num1:
dass ClassB extends ClassA
private static.int variable= 100
5 private int num2;
private ClassX objx
public ClassBint val1.int val2.ClassX obj
Superfval1
CassA.counter-=1
this.num2val2 +ClassB.variable: You're bee
10 this.objX= obj:
11
Publicint method101
12
return this.objX.method10 +this.getNum10+this.num2:
INIEGRAIED
MOCK- public ClassB(int val1,int val2,ClassX obj)
OBJ 21Dec20- Uperval1
Section assA.counter
this.num2 val2 +ClassB variabla
this.objX obj
Public int method10
3 return this.obiXmethod10 this getNum10+this.num2
ester
pubic static Void main(Sting args
ClassX obj1 new ClassX(20
ClassB obj2 Hnew ClassB(15 20 obj1)
stem.out.println(obj2.method10 +obj2.method20+CassA.counter You're E
10
11 12
190
ESIOR
IINIEGRKAIEU
MOCK-
mpot JAVA UTIL
OBJ 21Dec20- dass Demo
Section
Public static void main(String argsl)
new Demo0.display0
Moid display0
String inStr1-Welcome
Stem.out printwelcome'
a Unused import &print statement
b.Unused variable &package naming convention
CUnused varnable & method naming conventions You're b
10 d.Unused import & Class naming convention
11
a and d