-
What is the output of the following? // A simple example of recursion.class Factorial { // this is a recursive method int fact(int n) { int result; if(n==1) return 1; result = fact(n-1) * n; return result; }} class Recursion { public static void main(String args[]) { Factorial f = new Factorial(); System.out.println("Factorial of 3 is " + f.fact(3)); }}
A) Factorial of 3 is 3B) Factorial of 3 is 6C) Factorial of 3 is 9D) None of the above
-
-
-
-
The new operator dynamically allocates ________ for an object and returns a reference to it.
A) ClassesB) VariablesC) Memory D) None of the Above
-
Java allows objects to initialize themselves when they are created using _________
A) ArgumentsB) ClassesC) ConstructorsD) Parameters
-
Through _________ , you can control what parts of a program can access the members of a class
A) EncapsulationB) ClassC) InheritenceD) Polymorphism
-
When we create a class, we are creating a new data type
A) TrueB) False
-
A class is declared by use of the ________ keyword.
A) ObjectB) ClassC) Instance D) None of the above
-
The Code in java is contained within Methods
A) TrueB) False
-
-
-
A paramter is a variable defined by a method that receives a value when the method is called.
A) TrueB) FalseExplanation: A argument is a variable defined by a method that receives a value when the method is called.
-
-
In Java, all class objects need not be dynamically allocated
A) TrueB) False
-
-
-
-
-
Java Classes Questions
Ans