0% found this document useful (0 votes)
6 views7 pages

Continuous Assessment - 1

The document contains a series of programming questions related to Java, covering topics such as output of code snippets, variable scope, method overloading, access modifiers, and inheritance. Each question includes multiple-choice answers, testing knowledge of Java syntax and concepts. The questions are designed to assess understanding of Java programming fundamentals.

Uploaded by

jaimungi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views7 pages

Continuous Assessment - 1

The document contains a series of programming questions related to Java, covering topics such as output of code snippets, variable scope, method overloading, access modifiers, and inheritance. Each question includes multiple-choice answers, testing knowledge of Java syntax and concepts. The questions are designed to assess understanding of Java programming fundamentals.

Uploaded by

jaimungi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Assessment – 1

1. What will be the Output of the following Code?

class IncOp {
public static void main(String[] args) {
int g = 3;
System.out.print(++g * 8);
}
}

a. 32
b. 33
c. 24
d. 25

2. What will be the Output of the following Code?

class VarScope {
public static void main(String[] args) {
int x = 5;

{
int y = 6;
System.out.print(x + “ “ + y);
}

System.out.println(x + “ “ + y);
}
}

a. Compilation Error
b. Run Time Error
c. 5 6 5 6
d. 5 6 5
3. What will be the Output of the following Code?

class Array {
public static void main(String[] args) {
int[] arr = new int[5];

for(int i = 0; i < 5; i++) {


int t = i + 1;
arr[i] = t;
}

for(int i = 0; i < arr.length – 2; ++i)


System.out.print(arr[i] + “ “);
}
}

a. 1 2 3 4 5
b. 1 2 3 4
c. 1 2
d. 1 2 3

4. What will be the Output of the following Code?

class CmdArgTest {
public static void main(String[] args) {
if(args.length > 0)
System.out.print(args.length);
}
}

a. Program Compiles and Runs; but doesn’t Print anything


b. Program Compiles and Runs; Prints 0
c. Program Compiles and Runs; Prints 1
d. Program doesn’t Compile

5. What is the Extension of the Compiled JAVA Class File?


a. .txt
b. .js
c. .class
d. .java

6. Which of the following is a Selection Statement in JAVA?

a. break
b. continue
c. for()
d. if()

7. What will be the Output of the following JAVA Code?

class RecursionTest {
int fun(int n) {
int result;

if(n == 1)
return 1;

result = fun(n – 1);


return result;
}
}

class Output {
public static void main(String[] args) {
RecursionTest rec_t = new RecursionTest();
System.out.print(rec_t.fun(7));
}
}

a. 28
b. 1
c. 5040
d. None of these

8. Which of the following Methods represent Invalid Overloading?


a. void add(int, int, int); int add(int, int); float add(int, int);
b. void add(int, int); void add(int, int, int); void add(int, float);
c. int add(int, int); float add(int, int, int); double add(double, float, int);
d. All are Valid

9.Which of these Keywords is used to prevent Method Overriding?

a. static
b. constant
c. protected
d. final

10. Which Keyword is used to restrict the variable of a Class from inheriting to Child Class?

a. protected
b. private
c. public
d. static

11. The correct way of declaring an Object of a Class is :

a. ClassName objName = new ClassName();


b. ClassName objName = new ClassName;
c. objName = new ClassName;
d. new ClassName objName;

12. What will be the Output of the following Code?

class VarDeclare {
public static void main(String[] args) {
int z = 8;

if(z == 8) {
int z = 5;
System.out.println(z);
}
}
}

a. 5
b. 8
c. Compile Time Error
d. Run Time Error

13. All the Variables of a Class should be ideally declared as

a. private
b. public
c. protected
d. default

14. Which of the following Access means that a Variable is not accessible, even within the
Package?

a. private
b. public
c. default
d. protected

15. How many copies of Static variables and Class variables are created, when 10 Objects of a
Class are initialized?

a. 10, 10
b. 10, 1
c. 1, 10
d. 1, 1
16. Which data structure is used to handle Recursion?

a. Queue
b. Stack
c. Tree
d. Array

17. What will be the Output of the following Code?

class Compute {
public static void main(String[] args) {
double v1 = 1 + 7;
double v2 = v1 / 5;

int b3 = 1 + 7;
int b4 = b3 / 5;

System.out.print(v2 + “ “ + b4);
}
}

a. 1 1
b. 0 1
c. 1.6 1
d. 1.6 1.0

18. What will be the Output of the following Code?

class Operate {
public static void main(String[] args) {
int a = 1, b = 2, c, d;
c = ++b;
d = a++;

c++;
b++;
++a;

System.out.println(a + “ “ + b + “ “ + c);
}
}

a. 3 2 4
b. 3 2 3
c. 2 3 4
d. 3 4 4

19. The order of Constructor Call in Multi Level Inheritance is from _____ to _____; while the
order of Destructor Call is from _____ to _____.

a. Base, Child, Child, Base


b. Child, Base, Base, Child
c. Base, Child, Base, Child
d. Child, Base, Child, Base

20. A Base Class can have multiple Child Classes; this is possible in _____ Inheritance.

a. Multi Level
b. Hierarchical
c. Simple
d. All of these

You might also like