MCQOPTIONS
Bookmark
Saved Bookmarks
→
Java Programming
→
Exceptions
→
Can a class be declared with protected modifier?..
1.
Can a class be declared with protected modifier?
A.
False
B.
True
C.
NA
D.
NA
E.
NA
Answer» B. True
Show Answer
Discussion
No Comment Found
Post Comment
Related MCQs
What is the output of this program?<br><pre class="prettyprint lang-c"><br>class box_area <br> {<br> int w;<br> int l;<br> int h;<br> box_area() <br> {<br> w = 7;<br> l = 4;<br> h = 2;<br> }<br> void volume() <br> {<br> int vol = w * h * l;<br> System.out.println(vol);<br> } <br> } <br> public class cons_method <br> {<br> public static void main(String args[]) <br> {<br> box_area obj = new box_area();<br> obj.volume();<br> } <br> }<br></pre>
What is the output of this program?<br><pre class="prettyprint lang-c"><br>class modifier <br> {<br> static int p;<br> static int q;<br> void addition(int n1 , int n2)<br> {<br> p = n1 + n2;<br> q = p + n2;<br> }<br> } <br> public class static_use <br> {<br> public static void main(String args[])<br> {<br> modifier obj1 = new modifier();<br> modifier obj2 = new modifier(); <br> int n1 = 5;<br> obj1.addition(n1, n1 + 3);<br> obj2.addition(7, n1);<br> System.out.println(obj1.p + " " + obj2.q); <br> }<br> }<br></pre>
What is the output of this program?<br><pre class="prettyprint lang-c"><br>public class Result <br> {<br> static void main(String args[]) <br> { <br> int p , q = 1;<br> p = 20;<br> if(p != 20 && p / 0 == 0)<br> System.out.println(q);<br> else<br> System.out.println(++q);<br> } <br> }<br></pre>
What is the output of this program?<br><pre class="prettyprint lang-c"><br><br></pre>
What is the output of this program?<br><pre class="prettyprint lang-c"><br>class access_Example<br> {<br> public int p;<br> private int q;<br> void calc(int n1, int n2)<br> {<br> p = n1 + 1;<br> q = n2;<br> } <br> } <br> public class access_specifier <br> {<br> public static void main(String args[])<br> {<br> access_Example obj = new access_Example(); <br> obj.cal(5, 7);<br> System.out.println(obj.p + " " + obj.q); <br> }<br> }<br></pre>
What is the output of this program?<br><pre class="prettyprint lang-c"><br>class static_Access <br> {<br> static int p;<br> static int q;<br> void add(int n1, int n2)<br> {<br> p = n1 + n2;<br> q = p + n2;<br> }<br> } <br> public class static_output<br> {<br> public static void main(String args[])<br> {<br> static_Access obj1 = new static_Access();<br> static_Access obj2 = new static_Access(); <br> int n1 = 5;<br> obj1.add(n1, n1 + 2);<br> obj2.add(6, n1);<br> System.out.println(obj1.p + " " + obj2.q); <br> }<br> }<br></pre>
What is the output of this program?<br><pre class="prettyprint lang-c"><br>class modifier<br> {<br> static int p;<br> void method()<br> {<br> p++;<br> } <br> } <br> public class static_keyword<br> {<br> public static void main(String args[])<br> {<br> modifier obj1 = new modifier();<br> modifier obj2 = new modifier();<br> obj1.p = 5; <br> obj1.method();<br> obj2.method();<br> System.out.println(obj1.p + " " + obj2.p);<br> }<br> }<br></pre>
What is the output of this program?<br><pre class="prettyprint lang-c"><br>class Modifier<br> {<br> public int p;<br> static int q;<br> void cal(int n1, int n2)<br> {<br> p += n1;<br> q += n2;<br> } <br> } <br> public class static_keyword<br> {<br> public static void main(String args[])<br> {<br> Modifier obj1 = new Modifier();<br> Modifier obj2 = new Modifier(); <br> obj1.p = 2;<br> obj1.q = 3;<br> obj1.cal(4, 5);<br> obj2.p = 4;<br> obj2.cal(4, 6);<br> System.out.println(obj1.p + " " + obj2.q); <br> }<br> }<br></pre>
What happens if constructor of class N is made private?
Can a class be declared with protected modifier?
Reply to Comment
×
Name
*
Email
*
Comment
*
Submit Reply