• HOME
  • QUIZ
  • CONTACT US
EXAMIANS
  • COMPUTER
  • CURRENT AFFAIRS
  • ENGINEERING
    • Chemical Engineering
    • Civil Engineering
    • Computer Engineering
    • Electrical Engineering
    • Mechanical Engineering
  • ENGLISH GRAMMAR
  • GK
  • GUJARATI MCQ

Declaration and Access Control

Declaration and Access Control
Name the keyword that makes a variable belong to a class, rather than being defined for each instance of the class.

volatile
static
final
native
abstract

ANSWER DOWNLOAD EXAMIANS APP

Declaration and Access Control
What is the output for the below code ?public class A{ static{ System.out.println("static"); } { System.out.println("block"); } public A(){ System.out.println("A"); } public static void main(String[] args){ A a = new A(); }}

A block static
static A
static block A
None of these
A

ANSWER DOWNLOAD EXAMIANS APP

Declaration and Access Control
What can directly access and change the value of the variable qusNo?package com.mypackage;public class Test{ private int qusNo = 100;}

Any class.
Any class that extends Test.
Any class in com.mypackage package.
Only the Test class.
None of these

ANSWER DOWNLOAD EXAMIANS APP

Declaration and Access Control
What is the result of compiling and running the following code?class Base{ private Base(){ System.out.print("Base"); }}public class test extends Base{ public test(){ System.out.print("Derived"); } public static void main(String[] args){ new test(); }}

Compilation Error
Derived
BaseDerived
Exception is thrown at runtime

ANSWER DOWNLOAD EXAMIANS APP

Declaration and Access Control
What will be the output for the below code?public class Test{ static{ int a = 5; } public static void main(String[] args){ System.out.println(a); }}

Compile with error
5
0
None of these
Runtime Exception

ANSWER DOWNLOAD EXAMIANS APP

Declaration and Access Control
Choose the correct statement. Restriction on static methods are: I.   They can only call other static methods.II.   They must only access static data.III. They cannot refer this or super in any way.

Only (I)
(I), (II) and (III)
(II) and (III)
(I) and (II)
Only (III)

ANSWER DOWNLOAD EXAMIANS APP
MORE MCQ ON Declaration and Access Control

DOWNLOAD APP

  • APPLE
    from app store
  • ANDROID
    from play store

SEARCH

LOGIN HERE


  • GOOGLE

FIND US

  • 1.70K
    FOLLOW US
  • EXAMIANSSTUDY FOR YOUR DREAMS.
  • SUPPORT :SUPPORT EMAIL ACCOUNT : examians@yahoo.com

OTHER WEBSITES

  • GUJARATI MCQ
  • ACCOUNTIANS

QUICK LINKS

  • HOME
  • QUIZ
  • PRIVACY POLICY
  • DISCLAIMER
  • TERMS & CONDITIONS
  • CONTACT US
↑