Quizzes
Site Language: English
Українська
English
Русский
Programming Tests
Login
Sign Up
Programming Tests
Theory
Snippets
Papers
Landing
Android
Prices
FAQ
Cosmo Story
Terms and Conditions
Privacy Policy
Cookies Policy
Send Feedback
access modifiers
:
Content language: English
Русский
What is the result of the following code compilation and execution? public class Test extends A { public int i = 1; public static void main(String... args) { System.out.print(new Test().i); System.out.print(new A().i); System.out.print( ((A)new Test()).i ); } } class A { public int i = 2; }
access modifiers
Which access modifiers allow access to the field/method of a public class to other classes that are in the same package?
access modifiers
What will be the result of the work of the following program? class A { public A() { System.out.print("A "); } } class B { public B() { System.out.print("B "); } } public class Test { private A objA = new A(); private static B objB = new B(); public Test() { System.out.print("Test "); } public static void main(String[] args){ System.out.print("Main "); new Test(); } }
access modifiers
What access modifiers are allowed for the class if he is the only one in the file?
access modifiers
There are two classes: package pak1; import pak2.B; public class A { void doAThings() { System.out.print("A "); } public static void main(String[] args) { A a = new B(); a.doAThings(); } } and package pak2; import pak1.A; public class B extends A { public void doAThings() { System.out.println("I'm B ;)"); } } What will happen when you try to compile both classes and run the main-method?
access modifiers
How would you change declaration of function foo to ensure that a function foo is only accessible by classes defined in the package com.quizful ? package com.quizful class Foo { def foo = {...} }
access modifiers
Access modifiers
access modifiers
← Prev
1
Next →
Sign Up Now
or
Subscribe for future quizzes