Java Constructors and General Programming Quiz
A mixed quiz covering Java constructors, ASP.NET, .NET framework, C++ functions, AJAX, and various Java programming concepts including string manipulation and file operations.
Questions
What is the result of compiling and running the following code? String s=new String("hello"); StringBuffer sb=new StringBuffer("hello"); System.out.println(s.equals(sb));
- Compiler error: String and StringBuffer objects cannot be compared
- ClassCastException: String and StringBuffer objects cannot be compared
- Prints "true"
- Prints "false"
Which of the following compiles correctly if "f" is an instance of the File class?
- String[] s =f.list();
- File[] files=f.list();
- File[] files=f.listFiles();
- List files=f.listFiles();
What will happen when you attempt to compile and run the given code? 1. public class EqualsTest 2.{ 3. public static void main(String[] args) 4.{ 5. Boolean b = new Boolean(true); 6. String str = new String(""+b); 7. StringBuffer buff = new StringBuffer(str); 8. 9. System.out.println(b.equals(str) + ", " + 10. str.equals(buff) + ", " + 11. buff.equals(b)); 12. } 13. }
- It will print - false, true, false
- It will print - true, true, false
- It will print - false, false, false
- It will print - true, false, false
- Compilation error
- ClassCastException at runtime
Which of the following are true about the readPassword() method of the Console class? choose two
- Its return type is String
- It reads the password from the console
- It has echoing disabled
- It takes a single argument
- None of them
What is the result of compiling and running the following program? import java.util.Arrays; class Split2 { public static void main(String[] args) { String str = "She sells sea shells"; System.out.println(Arrays.toString(str.split("\s"))); } }
- Compiler error
- An exception is thrown at runtime
- Prints [She, sells, sea, shells]
- Prints [he, ells, ea, hells]
- Prints []
The .NET framework which provides automatic memory management using a technique called
- Overriding
- Garbage Collection
- Assemblies
- Serialization
Which browsers are supported by AJAX ?
- Internet Explorer 5.0
- Netscape 7.1
- Firefox 1.0
- All of Above
How to convert a string to integer?
- strtod()
- srttoi()
- atoi()
- None of these
What’s the .NET collection class that allows an element to be accessed using a unique key?
- ArrayList
- NameValue Collection
- StringCollection
- HashTable
Which method do you use to expllicitly to kill a user session?
- session.clear()
- session.dispose()
- Session.Abandon
- None
What’ is the sequence in which ASP.NET events are processed ?
- 1)Page_Init 2)Page_Load.3)Control events 4)Page_Unload event.
- 1)Page_Init 2)Page_Unload event..3)Control events 4)Page_Load
- 1)Page_Load 2)Page_Init 3)Control events 4)Page_Unload event.
- None
In ASP.NET the < authorization > section contain which of the following elements
- < allow >
- < deny>
- Both 1 and 2
- None
Constructors have no return type, not even void.
- True
- False
constructors can be abstract, final, native, static, or synchronized.
- True
- False
constructors can have any of the access modifiers: public, protected, private.
- True
- False
Constructors name is not same as their class name
- True
- False
Constructors use "this"(keyword) to refer to another constructor in the same class with a different parameter list
- True
- False
If a constructor uses this, it must not be in the constructor's first line
- True
- False
Interfaces have constructors
- True
- False
Every class in java has constructors including abstract classes
- True
- False