-
What modifiers may be used with an inner class that is a member of an outer class
A (non-local) inner class may be declared as public, protected, private, static, final, orabstract.
-
Is a class a subclass of itself
A class is a subclass of itself.
-
-
-
What is the unit for 1000 in the below statement?ob.sleep(1000)
A) Int millisecondsB) Double millisecondsC) long millisecondsD) Float milliseconds
-
-
Which of the following are true about the Error and Exception classes?
A) Both classes extend Throwable.B) The Error class is final and the Exception class is not.C) The Exception class is final and the Error is not.D) Both classes implement Throwable.
-
The term _____________ refers to a class's direct ancestor or to any of its ascendant classes.
Skill/Topic: InheritanceA) Sub ClassB) Super ClassC) Class hierarchy
-
Java I/O is based on the concept of _________
Skill/Topic: AWT & AppletsA) ClassesB) StreamsC) BuffersD) Threads
-
The concept of polymorphism is often expressed by the phrase
Skill/Topic: AWT & AppletsA) One interface, multiple methodsB) Multiple interface, one MethodC) Multiple interface, Multiple methodD) One interface, One method
-
_________ is used to destroy the objects created by the constructor methods.
Skill/Topic: AWT & AppletsA) finalize()
-
-
-
Parent p = new Parent(); // Can we access x using the p reference?
System.out.println("X in parent is " + p.x); // Compiler error!
}
}
when i compile this code it dosen't give any error.even though both classes are in diffrent package.
but in pdf it mentioned that it gives an error because you are trying to access the protected variable
using the instance of the super class
if the above code is write then what is logic behind the protected member of super class and if sub class
in different package try to access the member of the super class.">Hi,I am preparing for sjcp exam.my quetion is about the protected class. it have one super and sub class example ,below example i read from one pdf.package certification;public class Parent { protected int x = 9; // protected access}----------------------------package other;import certification.Parent;class Child extends Parent {public void testIt() { System.out.println("x is " + x); // No problem; Child inherits x Parent p = new Parent(); // Can we access x using the p reference? System.out.println("X in parent is " + p.x); // Compiler error!}}when i compile this code it dosen't give any error.even though both classes are in diffrent package. but in pdf it mentioned that it gives an error because you are trying to access the protected variableusing the instance of the super class if the above code is write then what is logic behind the protected member of super class and if sub classin different package try to access the member of the super class.
-
-
-
-
What is synchronization and why is it important
With respect to multithreading, synchronization is the capability to control the access ofmultiple threads to shared resources. Without synchronization, it is possible for onethread to modify a shared object while another thread is in the process of using orupdating that object's value. This often leads to significant errors.
-
-
What are wrapped classes
Wrapped classes are classes that allow primitive types to be accessed as objects.
Java Interview Questions
Ans