Java Programming Fundamentals
Test your knowledge of Java programming concepts including classes, methods, modifiers, inheritance, and program execution.
Questions
The following code creates one array and one string object. which object is eligible for garbage collection after the code executes? ... String[] students = new String[10]; String studentName = "Peter Parker"; students[0] = studentName; studentName = null; ...
- Array Object
- Neither Object
- String Objec
- Both of the Objects
Singleton class can have?
- More than one Object
- No Objects
- Only One Objects.
- Two Objects.
Identify the following. x. public final String getDetails(final File file, final String key) throws IOException y. getDetails(File, String)
- X is a method Signature and Y is a method Header
- Both X and Y is a method Header
- X is a method Header and Y is a method Signature
- Both X and Y is a method Signature
Static nested classes do not have access to
- Its non-static members
- Static members of the enclosing class
- Its Static members
- Non-Static members of the enclosing class
Facilities that are provided by Runtime class are:
- Reading data through key board
- Using system properties and environment variables
- Running non-java programs from within a java application.
- All of the Above
- None of the Above
Which of the following statements accurately describe the use of access modifiers within a class definition?
- They can be applied to both data & methods
- They must precede a class's data variables or methods
- They can follow a class's data variables or methods
- They can appear in any order
- They must be applied to data variables first and then to methods
What modifiers may be used with top-level class?
- Public
- Private
- Abstract
- Final
- Protected
class c1{ public static void main(String a[]) { c1 ob1=new c1(); Object ob2=ob1; System.out.println(ob2 instanceof Object); System.out.println(ob2 instanceof c1); } } What is the result of attempting to compile and run the program?
- Prints true,false
- Print false,true
- Prints true,true
- compile time error
class C{ public static void main(String a[]) { int i1=9; int i2; if(i1>3) { i2=8; } System.out.println(i2); }}What is the result of attempting to compile and run the program?
- compile time error
- Runtim error
- prints 8
- prints 0
interface I { //1 public class Inner { ///2 Inner ( ) { System .out . println ( "Inner Created" ) ; } }; }; What is the result of attempting to compile and run the program?
- compile time error at line 1
- compile time error at line 2
- the code compiles fine
- none of the above
public class withoutmain{ static{ System.out.println("without the main method"); System.exit(0); } } What is the result of attempting to compile and run the program ?
- Compile failure
- sucessfully compiled, but through exception in run time.
- It runs sucessfuly and prints "without the main method"
- It runs sucessfuly, but No output.
Class C { public static void main(String[] args) { int[]a1[]=new int[3][3]; //3 int a2[4]={3,4,5,6}; //4 int a2[5]; //5 } } What is the result of attempting to compile and run the program ?.
- compiletime error at lines 3,4,5
- compiltime error at line 4,5
- compiletime error at line 3
- Runtime Exception
class C1 { static interface I { static class C2 { } } public static void main(String a[]) { C1.I.C2 ob1=new C1.I.C2(); System.out.println("object created"); } } What is the result of attempting to compile and run the program?
- prints object created
- Compile time error
- Runtime Excepion
- None of the above
class C{ static int f1(int i) { System.out.print(i + ","); return 0; } public static void main (String[] args) { int i = 0; i = i++ + f1(i); System.out.print(i); } } What is the result of attempting to compile and run the program?
- Prints: 0,0
- Prints: 1,0
- Prints: 0,1
- Compile-time error
Which version of Visual Studio first supported Linq for defining standard query operators
- VS2003
- VS2005
- VS2008
- VS2010
The process of applying redo log files during recovery operation is called
- rolling backward
- restore
- recovery
- rolling forward