SlideShare a Scribd company logo
1 of 61
//Predict the Output
class num1{
public int a;
protected int b;
void data(int c, int d) {
a = c;
b = d;
System.out.println(a + " " + b);
}
}
class num2 extends num1{
public int mul;
void multiplication() {
mul = a * b;
}
}public class Main{
public static void main(String args[]) {
num2 obj = new num2();
obj.data(20, 30);
obj.multiplication();
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
20 30
Question 1
A)
60
B)
600
C)
Compilation error
D)
//Predict the Output
public class Main{
public static void main(String s[]){
Noodles eat = new Noodles();
eat.print();
}
}
class Maggi{
private int spoon = 3;
protected int sticks = 4;
}
class Noodles extends Maggi{
private int powder = 1;
protected int fire = 2;
void print()
{
System.out.println(powder + " " + fire + " " + sticks + " " +
spoon);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1 2 4 3
Question 2
A)
4 2 3 1
B)
1
C)
Compilation error
D)
//Predict the Output
public class Main{
public static void main(String s[]) {
Things t = new Things();t.print();
product p = new product();p.print();
System.out.println("~" + p.Thg2);
}
}
class product{
private int Thg1 = 3;
protected int Thg2 = 4;
void print() {
System.out.print("~" + Thg1);
}
}
class Things extends product{
private int Thg3 = 1;
protected int Thg4 = 2;
void print() {
System.out.print(Thg3 + "~" + Thg4 + "~" + Thg2);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1~2~4~3
Question 3
A)
1~2~4~3~4
B)
3
C)
Compilation error
D)
//Predict the Output
interface SixesMachine {
void hitSixes();
}
public abstract class DhoniInTheMaking implements SixesMachine {
public String numberOfSixes() {
return "6 0 6 3 6 6 6 6";
}
private void printRunsTrail(String runsAndRuns){
System.out.println(runsAndRuns);
}
}
class Dhoni extends DhoniInTheMaking {
public static void main(String args[]) {
DhoniInTheMaking outputClass = new Dhoni();
outputClass.hitSixes();
}
public void hitSixes() {
numberOfSixes().substring(5, 12);
printRunsTrail(numberOfSixes().substring(3, 7));
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
6 0 6 3 6 6 6 6
Question 4
A)
3 7
B)
5 12
C)
Compilation error
D)
//Predict the Output
public class Main
{
public static void main(String[] args)
{
Guess g = new Guess();
g.G();
Guess.CantGuess.ICanGuess.Hai hai = null;
hai.print();
}
}
class Guess {
protected void G() {
CantGuess cg = new CantGuess();
}
class CantGuess
{
public CantGuess()
{
System.out.print("Vowel");
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
ICanGuess icg = new ICanGuess();
GetICanGuess gicg = new GetICanGuess();
class ICanGuess {
public ICanGuess() {
System.out.print("Words");
}
Hai h = new Hai();
public class Hai {
public Hai() {
System.out.print("Check");
}
public void print() {
System.out.print("print");
}
}
}
class GetICanGuess {
public GetICanGuess(){
System.out.print("String");}
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
CheckWordsStringVowel prints the infinite time
Question 5
A)
CheckWordsStringVowel
B)
Run time error
C)
Compilation error
D)
//Predict the Output
public class Final{
int lanif = 37;
int nafi = 21;
public static void main(String[] args){
final Final f = new Final();f.process2();
f = modify(f);f.process();
}
public static final Final modify(final Final f){
f.process();
Final f2 = new Final();
f2.process();return f2;
}
final void process(){
lanif = nafi + nafi;
System.out.print(lanif + " " + nafi + " ");
}
void process2(){
nafi = lanif % 2;
System.out.print(nafi + " " + lanif + " ");
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1 37 2 1 42 21 42 21
Question 6
A)
18 37 36 18 42 21 42 21
B)
1 37 2 1 1 37 2 1
C)
Compilation error
D)
//Predict the Output
public class Main
{
final static short i = 2;
public static int j = 0;
public static void main(String [] args)
{
for (int k = 0; k < 3; k++)
{
switch (k)
{
case i: System.out.print(" 0 ");
case i-1: System.out.print(" 1 ");
case i-2: System.out.print(" 2 ");
}
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2 1 0 1 0 0
Question 7
A)
0 1 2 1 2 2
B)
2 1 2 0 1 2
C)
Compilation error
D)
//Predict the Output
public class Final
{
int a = 30;
public static void main(String[] args)
{
final int assign;
Final b = new Final();
process(b);
System.out.println(b.a);
process(b);
assign = b.a;
System.out.println(assign);
}
public static void process(Final a)
{
a.a = a.a + 5;
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
35
40
Question 8
A)
30
45
B)
40
C)
Compilation error
D)
//Predict the Output
public class Final
{
public static void main(String[] args)
{
final String result = "Focus";
final String assign;
Final f = new Final();
assign = "academy";
final String xchange = " ";
System.out.println(process(result, assign, xchange));
}
static String process(String a, String b, String xchange)
{
xchange = b + " " + a;
return xchange;
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Focus
Question 9
A)
Focus academy
B)
academy Focus
C)
Compilation error
D)
//Predict the Output
public class Result
{
public static void main(String args[])
{
B b = new B();
System.out.println("x = " + b.getResult(0, 1));
}
}
class A
{
final public int getResult(int a, int b) { return a * b; }
}
class B extends A
{
public int getResult(int a, int b) { return a + b; }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
x = 1
Question 10
A)
x = 0
B)
Runtime error
C)
Compilation error
D)
//Predict the Output
public final class FinalPersonClass {
private final String name;
private final int age;
public FinalPersonClass(final String name, final int age){
super();
this.name = name;
this.age = age;
}
public int getAge() {
return age;
}
public String getName(){
return name;
}
public static void main(String[] args) {
FinalPersonClass fpc = new FinalPersonClass("Arun", 24);
FinalPersonClass fc = new FinalPersonClass("Kiran", 25);
System.out.println(fpc.name + " - " + fpc.age);
System.out.println(fc.getName() + " - " + fc.getAge());
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Arun - 24
Kiran - 25
Question 11
A)
Arun - 24
Arun - 24
B)
Kiran – 25
Kiran - 25
C)
Compilation error
D)
//Predict the Output
public class Circle
{
private double radius;
public Circle(double radius)
{
radius = radius;
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
The program does not compile because Circle does not have a default
constructor
Question 12
A)
The program will compile, but we cannot create an object of
Circle with a specified radius. The object will always have radius 0.
B)
The program has a compilation error because it does not have a main
method.
C)
The program has a compilation error because we cannot assign radius to
radius.
D)
//Predict the Output
public class Drive
{
static int i = demo();
static
{
System.out.print(i);
}
Drive()
{
System.out.print("String2");
}
public static void main(String args[])
{
System.out.print("String1");
}
static int demo()
{
System.out.print("Drive");
return 10;
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
10String1
Question 13
A)
Drive10String1
B)
Drive10
C)
Compilation error
D)
//Predict the Output
class Static{
static int x;
static int y;
void add(int a, int b){
x = a + b;
y = x + b;
}
}
public class static_use
{
public static void main(String args[])
{
Static obj1 = new Static();
Static obj2 = new Static();
int a = 2;
obj1.add(a, a + 1);
obj2.add(5, a);
System.out.println(obj1.x + " " + obj2.y);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2 10
Question 14
A)
7 9
B)
2 2
C)
Compilation error
D)
//Predict the Output
public class Methods
{
static int x = 100;
int y = 100;
public void increment()
{
x++; y++;
}
public static void main( String[] args )
{
Methods t1 = new Methods();
Methods t2 = new Methods();
t1.increment();
t2.increment();
System.out.println(t2.y);
System.out.println(Methods.x);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
100 prints infinite time
100
Question 15
A)
100
100
B)
101
102
C)
Compilation error
D)
//Predict the Output
public class Main
{
public static void square(int x)
{
System.out.println(x*x);
}
public static void main (String[] arg)
{
square(8);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
8
Question 16
A)
64
B)
64 prints infinite time
C)
Compilation error
D)
//Predict the Output
public class Main
{
void MethodOfClassA()
{
System.out.println("Method of ClassA");
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Main method not found in class
Question 17
A)
Method of ClassA
B)
It will throws an Error
C)
Methods of ClassA prints infinite time
D)
//Predict the Output
public class A
{
private : int sum(int x, int y)
{
return x+y;
}
public: A()
{
}
A(int x, int y)
{
cout&lt;&lt;sum(x,y);
}
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Constructor will give error if float values are passed
Question 18
A)
Constructor can be created with zero argument
B)
Constructor prints sum, if two parameters are passed with object
creation
C)
Constructor will take 0 as default value of parameters if not passed
D)
Given a method in a protected class, what access modifier do you use to
restrict access to that method to only the other members of the same class?
private
Question 19
A)
protected
B)
static
C)
final
D)
If class A has add() function with protected access, and few other members
in public.Then class B inherits class A privately. Will the user will not be able
to call _________ from the object of class B.
Any member of class A
Question 20
A)
Any function of class A
B)
The add() function of class A
C)
Private, protected and public members of class A
D)
//Predict the Output
class Methods
{
private double num = 100;
private int square(int a)
{
return a*a;
}
}
public class Main
{
public static void main(String args[])
{
Methods obj = new Methods();
System.out.println(obj.num);
System.out.println(obj.square(10));
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
100
10
Question 21
A)
100
1000
B)
1000
10
C)
Compilation Error
D)
Question 22
Which is valid in a class that extends class A?
class A
{
protected int method1(int a, int b)
{
return 0;
}
}
private int method1(int a, int b) { return 0; }
Question 22
A)
public int method1(int a, int b) {return 0; }
B)
public short method1(int a, int b) { return 0; }
C)
static protected int method1(int a, int b) { return 0; }
D)
//Predict the Output
public class Main
{
public static void main(String args[])
{
class Goto
{
public int i = 3;
}
Object t1 = (Object)new Goto();
Goto obj = (Goto)t1;
System.out.println("i = " + obj.i);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
i = 1
Question 23
A)
i = 0
B)
i = 3
C)
Compilation error
D)
//Predict the Output
public class Methods
{
public int Method()
{
static int i = 0;
i++;
return i;
}
public static void main(String args[])
{
Methods test = new Methods();
test.Method();
int j = test.Method();
System.out.println(j);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1
Question 24
A)
0
B)
1 2 3 4 5
C)
Compilation error
D)
//Predict the Output
class Base
{
Base()
{
System.out.print("Focus");
}
}
public class Alpha extends Base
{
public static void main(String[] args)
{
new Alpha();
new Base();
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
0
Question 25
A)
Focus
B)
FocusFocus
C)
Compilation error
D)
//Predict the Output
import java.util.*;
public class NewTrees extends NewTree
{
public static void main(String [] args)
{
NewTrees t = new NewTrees();
t.count();
}
}
protected class NewTree
{
void count()
{
for (int x = 0; x < 5; x++,x++ )
{
System.out.print(" " + x);
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
0 2
Question 26
A)
0 2 4
B)
Compilation fails at line 3
C)
Compilation fails at line 11
D)
//Predict the Output
public class Main
{
public static void main(String[ ] args)
{
float f1[ ], f2[ ];
f1 = new float[10];
f2 = f1;
System.out.println(f2[0]);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
0.1
Question 27
A)
10.0
B)
0.0
C)
Compilation error
D)
//Predict the Output
class Super
{
public Integer getLength()
{
return new Integer(4);
}
}
public class Sub extends Super
{
public Long getLength()
{
return new Long(5);
}
public static void main(String[] args)
{
Super obj = new Super();
Sub sub = new Sub();
System.out.println(obj.getLength().toString() + "," +
sub.getLength().toString());
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
4.0
Question 28
A)
4
B)
5.0
C)
Compilation error
D)
//Predict the Output
interface Count
{
short counter = 0;
void countUp();
}
public class TestCount implements Count
{
public static void main(String [] args)
{
TestCount t = new TestCount();
t.countUp();
}
public void countUp()
{
for (int x = 6; x>counter; x--, ++counter)
{
System.out.print(" " + counter);
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1 2
Question 29
A)
1 2 3
B)
1 2 3 4
C)
Compilation error
D)
//Predict the Output
public class Outer
{
public void someOuterMethod()
{
//Line 6
}
public class Inner { }
public static void main(String[] argv)
{
Outer ot = new Outer();
//Line 12
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
new ot.Inner(); //At line 12
Question 30
A)
new Inner(); //At line 6
B)
new Inner(); //At line 12
C)
new Outer.Inner(); //At line 6
D)
THANK YOU

More Related Content

Similar to WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14_Access_Specifiers_MCQs_1.2.pptx

OBJECT ORIENTED PROGRAMMIING LANGUAGE PROGRAMS
OBJECT ORIENTED PROGRAMMIING LANGUAGE PROGRAMSOBJECT ORIENTED PROGRAMMIING LANGUAGE PROGRAMS
OBJECT ORIENTED PROGRAMMIING LANGUAGE PROGRAMSRohit Kumar
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Mar-2021_L13...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Mar-2021_L13...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Mar-2021_L13...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Mar-2021_L13...MaruMengesha
 
java slip for bachelors of business administration.pdf
java slip for bachelors of business administration.pdfjava slip for bachelors of business administration.pdf
java slip for bachelors of business administration.pdfkokah57440
 
1z0 851 exam-java standard edition 6 programmer certified professional
1z0 851 exam-java standard edition 6 programmer certified professional1z0 851 exam-java standard edition 6 programmer certified professional
1z0 851 exam-java standard edition 6 programmer certified professionalIsabella789
 
Chapter i(introduction to java)
Chapter i(introduction to java)Chapter i(introduction to java)
Chapter i(introduction to java)Chhom Karath
 
Core java pract_sem iii
Core java pract_sem iiiCore java pract_sem iii
Core java pract_sem iiiNiraj Bharambe
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Feb-2021_L2_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Feb-2021_L2_...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Feb-2021_L2_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Feb-2021_L2_...MaruMengesha
 
Wap to implement bitwise operators
Wap to implement bitwise operatorsWap to implement bitwise operators
Wap to implement bitwise operatorsHarleen Sodhi
 
I dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdfI dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdfarchanaemporium
 
Java_practical_handbook
Java_practical_handbookJava_practical_handbook
Java_practical_handbookManusha Dilan
 

Similar to WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14_Access_Specifiers_MCQs_1.2.pptx (20)

OBJECT ORIENTED PROGRAMMIING LANGUAGE PROGRAMS
OBJECT ORIENTED PROGRAMMIING LANGUAGE PROGRAMSOBJECT ORIENTED PROGRAMMIING LANGUAGE PROGRAMS
OBJECT ORIENTED PROGRAMMIING LANGUAGE PROGRAMS
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Mar-2021_L13...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Mar-2021_L13...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Mar-2021_L13...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Mar-2021_L13...
 
Java practical
Java practicalJava practical
Java practical
 
java slip for bachelors of business administration.pdf
java slip for bachelors of business administration.pdfjava slip for bachelors of business administration.pdf
java slip for bachelors of business administration.pdf
 
C++ programs
C++ programsC++ programs
C++ programs
 
Unit-3 Practice Programs-5.docx
Unit-3 Practice Programs-5.docxUnit-3 Practice Programs-5.docx
Unit-3 Practice Programs-5.docx
 
Scjp6.0
Scjp6.0Scjp6.0
Scjp6.0
 
1z0 851 exam-java standard edition 6 programmer certified professional
1z0 851 exam-java standard edition 6 programmer certified professional1z0 851 exam-java standard edition 6 programmer certified professional
1z0 851 exam-java standard edition 6 programmer certified professional
 
7
77
7
 
5 Rmi Print
5  Rmi Print5  Rmi Print
5 Rmi Print
 
Oops Quiz
Oops QuizOops Quiz
Oops Quiz
 
Java Program
Java ProgramJava Program
Java Program
 
Chapter i(introduction to java)
Chapter i(introduction to java)Chapter i(introduction to java)
Chapter i(introduction to java)
 
Core java pract_sem iii
Core java pract_sem iiiCore java pract_sem iii
Core java pract_sem iii
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Feb-2021_L2_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Feb-2021_L2_...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Feb-2021_L2_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Feb-2021_L2_...
 
Wap to implement bitwise operators
Wap to implement bitwise operatorsWap to implement bitwise operators
Wap to implement bitwise operators
 
I dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdfI dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdf
 
Java_practical_handbook
Java_practical_handbookJava_practical_handbook
Java_practical_handbook
 
sample_midterm.pdf
sample_midterm.pdfsample_midterm.pdf
sample_midterm.pdf
 
Sam wd programs
Sam wd programsSam wd programs
Sam wd programs
 

More from MaruMengesha

WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_22-Feb-2021_L9-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_22-Feb-2021_L9-...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_22-Feb-2021_L9-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_22-Feb-2021_L9-...MaruMengesha
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...MaruMengesha
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Mar-2021_L15...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Mar-2021_L15...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Mar-2021_L15...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Mar-2021_L15...MaruMengesha
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Feb-2021_L6-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Feb-2021_L6-...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Feb-2021_L6-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Feb-2021_L6-...MaruMengesha
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_11-Feb-2021_L5-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_11-Feb-2021_L5-...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_11-Feb-2021_L5-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_11-Feb-2021_L5-...MaruMengesha
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_10-Feb-2021_L4_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_10-Feb-2021_L4_...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_10-Feb-2021_L4_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_10-Feb-2021_L4_...MaruMengesha
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...MaruMengesha
 
Chemistry Student G9.pdf chemistry text book
Chemistry Student G9.pdf chemistry text bookChemistry Student G9.pdf chemistry text book
Chemistry Student G9.pdf chemistry text bookMaruMengesha
 
eco ppt.pptx Economics presentation Assignment
eco ppt.pptx Economics presentation Assignmenteco ppt.pptx Economics presentation Assignment
eco ppt.pptx Economics presentation AssignmentMaruMengesha
 
G12-Agriculture-STB-2023-web.pdf Agriculture text book
G12-Agriculture-STB-2023-web.pdf Agriculture text bookG12-Agriculture-STB-2023-web.pdf Agriculture text book
G12-Agriculture-STB-2023-web.pdf Agriculture text bookMaruMengesha
 

More from MaruMengesha (10)

WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_22-Feb-2021_L9-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_22-Feb-2021_L9-...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_22-Feb-2021_L9-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_22-Feb-2021_L9-...
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Mar-2021_L15...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Mar-2021_L15...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Mar-2021_L15...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Mar-2021_L15...
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Feb-2021_L6-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Feb-2021_L6-...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Feb-2021_L6-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Feb-2021_L6-...
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_11-Feb-2021_L5-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_11-Feb-2021_L5-...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_11-Feb-2021_L5-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_11-Feb-2021_L5-...
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_10-Feb-2021_L4_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_10-Feb-2021_L4_...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_10-Feb-2021_L4_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_10-Feb-2021_L4_...
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...
 
Chemistry Student G9.pdf chemistry text book
Chemistry Student G9.pdf chemistry text bookChemistry Student G9.pdf chemistry text book
Chemistry Student G9.pdf chemistry text book
 
eco ppt.pptx Economics presentation Assignment
eco ppt.pptx Economics presentation Assignmenteco ppt.pptx Economics presentation Assignment
eco ppt.pptx Economics presentation Assignment
 
G12-Agriculture-STB-2023-web.pdf Agriculture text book
G12-Agriculture-STB-2023-web.pdf Agriculture text bookG12-Agriculture-STB-2023-web.pdf Agriculture text book
G12-Agriculture-STB-2023-web.pdf Agriculture text book
 

Recently uploaded

BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 

Recently uploaded (20)

BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 

WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14_Access_Specifiers_MCQs_1.2.pptx

  • 1.
  • 2. //Predict the Output class num1{ public int a; protected int b; void data(int c, int d) { a = c; b = d; System.out.println(a + " " + b); } } class num2 extends num1{ public int mul; void multiplication() { mul = a * b; } }public class Main{ public static void main(String args[]) { num2 obj = new num2(); obj.data(20, 30); obj.multiplication(); } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 4. //Predict the Output public class Main{ public static void main(String s[]){ Noodles eat = new Noodles(); eat.print(); } } class Maggi{ private int spoon = 3; protected int sticks = 4; } class Noodles extends Maggi{ private int powder = 1; protected int fire = 2; void print() { System.out.println(powder + " " + fire + " " + sticks + " " + spoon); } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 5. 1 2 4 3 Question 2 A) 4 2 3 1 B) 1 C) Compilation error D)
  • 6. //Predict the Output public class Main{ public static void main(String s[]) { Things t = new Things();t.print(); product p = new product();p.print(); System.out.println("~" + p.Thg2); } } class product{ private int Thg1 = 3; protected int Thg2 = 4; void print() { System.out.print("~" + Thg1); } } class Things extends product{ private int Thg3 = 1; protected int Thg4 = 2; void print() { System.out.print(Thg3 + "~" + Thg4 + "~" + Thg2); } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 8. //Predict the Output interface SixesMachine { void hitSixes(); } public abstract class DhoniInTheMaking implements SixesMachine { public String numberOfSixes() { return "6 0 6 3 6 6 6 6"; } private void printRunsTrail(String runsAndRuns){ System.out.println(runsAndRuns); } } class Dhoni extends DhoniInTheMaking { public static void main(String args[]) { DhoniInTheMaking outputClass = new Dhoni(); outputClass.hitSixes(); } public void hitSixes() { numberOfSixes().substring(5, 12); printRunsTrail(numberOfSixes().substring(3, 7)); } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 9. 6 0 6 3 6 6 6 6 Question 4 A) 3 7 B) 5 12 C) Compilation error D)
  • 10. //Predict the Output public class Main { public static void main(String[] args) { Guess g = new Guess(); g.G(); Guess.CantGuess.ICanGuess.Hai hai = null; hai.print(); } } class Guess { protected void G() { CantGuess cg = new CantGuess(); } class CantGuess { public CantGuess() { System.out.print("Vowel"); } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 11. ICanGuess icg = new ICanGuess(); GetICanGuess gicg = new GetICanGuess(); class ICanGuess { public ICanGuess() { System.out.print("Words"); } Hai h = new Hai(); public class Hai { public Hai() { System.out.print("Check"); } public void print() { System.out.print("print"); } } } class GetICanGuess { public GetICanGuess(){ System.out.print("String");} } } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 12. CheckWordsStringVowel prints the infinite time Question 5 A) CheckWordsStringVowel B) Run time error C) Compilation error D)
  • 13. //Predict the Output public class Final{ int lanif = 37; int nafi = 21; public static void main(String[] args){ final Final f = new Final();f.process2(); f = modify(f);f.process(); } public static final Final modify(final Final f){ f.process(); Final f2 = new Final(); f2.process();return f2; } final void process(){ lanif = nafi + nafi; System.out.print(lanif + " " + nafi + " "); } void process2(){ nafi = lanif % 2; System.out.print(nafi + " " + lanif + " "); } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 14. 1 37 2 1 42 21 42 21 Question 6 A) 18 37 36 18 42 21 42 21 B) 1 37 2 1 1 37 2 1 C) Compilation error D)
  • 15. //Predict the Output public class Main { final static short i = 2; public static int j = 0; public static void main(String [] args) { for (int k = 0; k < 3; k++) { switch (k) { case i: System.out.print(" 0 "); case i-1: System.out.print(" 1 "); case i-2: System.out.print(" 2 "); } } } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 16. 2 1 0 1 0 0 Question 7 A) 0 1 2 1 2 2 B) 2 1 2 0 1 2 C) Compilation error D)
  • 17. //Predict the Output public class Final { int a = 30; public static void main(String[] args) { final int assign; Final b = new Final(); process(b); System.out.println(b.a); process(b); assign = b.a; System.out.println(assign); } public static void process(Final a) { a.a = a.a + 5; } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 19. //Predict the Output public class Final { public static void main(String[] args) { final String result = "Focus"; final String assign; Final f = new Final(); assign = "academy"; final String xchange = " "; System.out.println(process(result, assign, xchange)); } static String process(String a, String b, String xchange) { xchange = b + " " + a; return xchange; } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 20. Focus Question 9 A) Focus academy B) academy Focus C) Compilation error D)
  • 21. //Predict the Output public class Result { public static void main(String args[]) { B b = new B(); System.out.println("x = " + b.getResult(0, 1)); } } class A { final public int getResult(int a, int b) { return a * b; } } class B extends A { public int getResult(int a, int b) { return a + b; } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 22. x = 1 Question 10 A) x = 0 B) Runtime error C) Compilation error D)
  • 23. //Predict the Output public final class FinalPersonClass { private final String name; private final int age; public FinalPersonClass(final String name, final int age){ super(); this.name = name; this.age = age; } public int getAge() { return age; } public String getName(){ return name; } public static void main(String[] args) { FinalPersonClass fpc = new FinalPersonClass("Arun", 24); FinalPersonClass fc = new FinalPersonClass("Kiran", 25); System.out.println(fpc.name + " - " + fpc.age); System.out.println(fc.getName() + " - " + fc.getAge()); } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 24. Arun - 24 Kiran - 25 Question 11 A) Arun - 24 Arun - 24 B) Kiran – 25 Kiran - 25 C) Compilation error D)
  • 25. //Predict the Output public class Circle { private double radius; public Circle(double radius) { radius = radius; } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 26. The program does not compile because Circle does not have a default constructor Question 12 A) The program will compile, but we cannot create an object of Circle with a specified radius. The object will always have radius 0. B) The program has a compilation error because it does not have a main method. C) The program has a compilation error because we cannot assign radius to radius. D)
  • 27. //Predict the Output public class Drive { static int i = demo(); static { System.out.print(i); } Drive() { System.out.print("String2"); } public static void main(String args[]) { System.out.print("String1"); } static int demo() { System.out.print("Drive"); return 10; } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 29. //Predict the Output class Static{ static int x; static int y; void add(int a, int b){ x = a + b; y = x + b; } } public class static_use { public static void main(String args[]) { Static obj1 = new Static(); Static obj2 = new Static(); int a = 2; obj1.add(a, a + 1); obj2.add(5, a); System.out.println(obj1.x + " " + obj2.y); } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 30. 2 10 Question 14 A) 7 9 B) 2 2 C) Compilation error D)
  • 31. //Predict the Output public class Methods { static int x = 100; int y = 100; public void increment() { x++; y++; } public static void main( String[] args ) { Methods t1 = new Methods(); Methods t2 = new Methods(); t1.increment(); t2.increment(); System.out.println(t2.y); System.out.println(Methods.x); } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 32. 100 prints infinite time 100 Question 15 A) 100 100 B) 101 102 C) Compilation error D)
  • 33. //Predict the Output public class Main { public static void square(int x) { System.out.println(x*x); } public static void main (String[] arg) { square(8); } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 34. 8 Question 16 A) 64 B) 64 prints infinite time C) Compilation error D)
  • 35. //Predict the Output public class Main { void MethodOfClassA() { System.out.println("Method of ClassA"); } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 36. Main method not found in class Question 17 A) Method of ClassA B) It will throws an Error C) Methods of ClassA prints infinite time D)
  • 37. //Predict the Output public class A { private : int sum(int x, int y) { return x+y; } public: A() { } A(int x, int y) { cout&lt;&lt;sum(x,y); } }; 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 38. Constructor will give error if float values are passed Question 18 A) Constructor can be created with zero argument B) Constructor prints sum, if two parameters are passed with object creation C) Constructor will take 0 as default value of parameters if not passed D)
  • 39. Given a method in a protected class, what access modifier do you use to restrict access to that method to only the other members of the same class? private Question 19 A) protected B) static C) final D)
  • 40. If class A has add() function with protected access, and few other members in public.Then class B inherits class A privately. Will the user will not be able to call _________ from the object of class B. Any member of class A Question 20 A) Any function of class A B) The add() function of class A C) Private, protected and public members of class A D)
  • 41. //Predict the Output class Methods { private double num = 100; private int square(int a) { return a*a; } } public class Main { public static void main(String args[]) { Methods obj = new Methods(); System.out.println(obj.num); System.out.println(obj.square(10)); } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 43. Question 22 Which is valid in a class that extends class A? class A { protected int method1(int a, int b) { return 0; } }
  • 44. private int method1(int a, int b) { return 0; } Question 22 A) public int method1(int a, int b) {return 0; } B) public short method1(int a, int b) { return 0; } C) static protected int method1(int a, int b) { return 0; } D)
  • 45. //Predict the Output public class Main { public static void main(String args[]) { class Goto { public int i = 3; } Object t1 = (Object)new Goto(); Goto obj = (Goto)t1; System.out.println("i = " + obj.i); } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 46. i = 1 Question 23 A) i = 0 B) i = 3 C) Compilation error D)
  • 47. //Predict the Output public class Methods { public int Method() { static int i = 0; i++; return i; } public static void main(String args[]) { Methods test = new Methods(); test.Method(); int j = test.Method(); System.out.println(j); } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 48. 1 Question 24 A) 0 B) 1 2 3 4 5 C) Compilation error D)
  • 49. //Predict the Output class Base { Base() { System.out.print("Focus"); } } public class Alpha extends Base { public static void main(String[] args) { new Alpha(); new Base(); } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 51. //Predict the Output import java.util.*; public class NewTrees extends NewTree { public static void main(String [] args) { NewTrees t = new NewTrees(); t.count(); } } protected class NewTree { void count() { for (int x = 0; x < 5; x++,x++ ) { System.out.print(" " + x); } } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 52. 0 2 Question 26 A) 0 2 4 B) Compilation fails at line 3 C) Compilation fails at line 11 D)
  • 53. //Predict the Output public class Main { public static void main(String[ ] args) { float f1[ ], f2[ ]; f1 = new float[10]; f2 = f1; System.out.println(f2[0]); } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 55. //Predict the Output class Super { public Integer getLength() { return new Integer(4); } } public class Sub extends Super { public Long getLength() { return new Long(5); } public static void main(String[] args) { Super obj = new Super(); Sub sub = new Sub(); System.out.println(obj.getLength().toString() + "," + sub.getLength().toString()); } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 57. //Predict the Output interface Count { short counter = 0; void countUp(); } public class TestCount implements Count { public static void main(String [] args) { TestCount t = new TestCount(); t.countUp(); } public void countUp() { for (int x = 6; x>counter; x--, ++counter) { System.out.print(" " + counter); } } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 58. 1 2 Question 29 A) 1 2 3 B) 1 2 3 4 C) Compilation error D)
  • 59. //Predict the Output public class Outer { public void someOuterMethod() { //Line 6 } public class Inner { } public static void main(String[] argv) { Outer ot = new Outer(); //Line 12 } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 60. new ot.Inner(); //At line 12 Question 30 A) new Inner(); //At line 6 B) new Inner(); //At line 12 C) new Outer.Inner(); //At line 6 D)

Editor's Notes

  1. 1st slide (Mandatory)
  2. Extra Large Options (3 lines)
  3. MCQ coding question (Programming)
  4. Thank you slide