Correct Answer: Wrapping is also called as packing or boxing Storing the data inside the object as private data which can accessed outside the class only by using methods
2. What is different among String, StringBuffer, StringBuilder?
Correct Answer: String class objects are immutable objects and they represents strings( sequence of characters) StringBuffer class objects are mutable objects representing strings and they are Thread safe StringBuild class objects are also mutable objects representing strings and they are not Thread safe
Correct Answer: new ClassName( arg1, arg2, argN); Ex: Class sample { Sample(int a) { Systemoutprintln("arg con a =" +a); } } class Demo { Public static void main( String[] args) { Sample s1= new Sample(23); Sample s2= new Sample(45); } }
Correct Answer: Constructor is not a special method Constructor is block of code that is executed automatically whenever object of the class is created
Correct Answer: Method contains name, parameters, return type and executable body But block does not contains name, parameters, return typeIt contains only executable body Methods are executed by method call statements Blocks are executed automatically with class loading and with object creation
6. What is JAR file? what are the main uses of JAR files?
Correct Answer: JAR files are java's version of ZIP files In fact, JAR uses the ZIP file format uses: - to compress a number of class files into one file - to make a java executable JAR file
7. What is the difference between path and classpath?
Correct Answer: - By using method overriding a sub class can change the definition of super class method - By using overriding a sub class can modify the functionality of the super class