0% found this document useful (0 votes)
2 views8 pages

01 Software Tester - Java Programming Fundamental

Uploaded by

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

01 Software Tester - Java Programming Fundamental

Uploaded by

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

Software Tester

Java Programming Fundamental & OOP

1. Which of the following is not a Java keyword?

a) class
b) interface
c) extends
d) include

2. Which method must be implemented by all threads?

a) start()
b) run()
c) execute()
d) main()

3. What is the default value of a boolean variable in Java?

a) true
b) false
c) 0
d) null

4. What does OOP stand for?

a) Object Oriented Programming


b) Objective Oriented Programming
c) Object Oriented Process
d) Object Oriented Principles

5. Which concept of OOP is used to reuse the code?

a) Encapsulation
b) Inheritance
c) Polymorphism
d) Abstraction
6. Which of the following is a valid declaration of an abstract method?

a) public void method() { }


b) public abstract void method();
c) public abstract void method() { }
d) abstract void method() { }

7. What is the output of the following code:


System.out.println(10 + 20 + "Hello");

a) 30Hello
b) 1020Hello
c) Hello30
d) Hello1020

8. Which of the following is not a type of constructor in Java?

a) Default constructor
b) No-arg constructor
c) Parameterized constructor
d) Static constructor

9. What is the purpose of the final keyword in Java?

a) To define a constant
b) To prevent method overriding
c) To prevent inheritance
d) All of the above

10. Which of the following is a correct way to declare a variable in Java ?


- A) `int number`;
- B) `number int`;
- C) `declare int number`;
- D) `int = number`;
11. What is the default value of a local variable in Java ?
- A) 0
- B) null
- C) undefined
- D) No default value

12. Which of the following methods is used to start a thread in Java ?


- A) `init`)(
- B) `start`)(
- C) `run`)(
- D) `begin`)(

13. Which access modifier is used to make a member of a class visible only within the same
package?
- A) `private`
- B) `public`
- C) `protected`
- D) Default (no modifier)

14. Which of the following is an example of a ternary operator in Java ?


- A) x > y ? x : y
- B) x = y + z
- C) x && y
- D) x + y
15. What is inheritance in Java?
- A) A way to create new classes from existing classes
- B) A way to hide data within a class
- C) A type of conditional statement
- D) A method of file I/O

16. What is the purpose of the `super` keyword in Java ?


- A) To refer to the current object
- B) To call the constructor of a parent class
- C) To create a new object
- D) To define a static method

17. Which of the following is not a feature of Java?


- A) Object-oriented
- B) Platform-independent
- C) High performance
- D) Pointer arithmetic

18. What is the result of the following expression in Java:


System.out.println("Hello" +10 + 20);

a) 30Hello
b) 1020Hello
c) Hello30
d) Hello1020
19. Which of the following is true about Java?
- A) Java supports multiple inheritance through classes
- B) Java does not support interfaces
- C) Java is a procedural programming language
- D) Java is a platform-independent language

20. Which collection class allows you to grow or shrink its size and provides indexed access to
its elements but whose methods are not synchronized?
- A) java.util.HashSet
- B) java.util.LinkedList
- C) java.util.ArrayList
- D) java.util.TreeSet

21. Which of the following is a marker interface in Java ?


- A) `Serializable`
- B) `Runnable`
- C) `Cloneable`
- D) Both A and C

22. What does the `final` keyword mean when applied to a variable?
- A) The variable is mutable
- B) The variable is immutable
- C) The variable is thread-safe
- D) The variable is null
23. Which of the following statements is true about constructors in Java ?
- A) Constructors cannot be overloaded
- B) Constructors do not have a return type
- C) Constructors are inherited
- D) Constructors can be abstract

24. What is the correct way to handle exceptions in Java ?


- A) Using `try` and `catch` blocks
- B) Using `if` and `else` statements
- C) Using `goto` statements
- D) Using `switch` statements
25. What is the output of the following program?

class Derived
{
public void getDetails()
{
System.out.printf("Derived class ");
}
}

public class Test extends Derived


{
public void getDetails()
{
System.out.printf("Test class ");
super.getDetails();
}
public static void main(String[] args)
{
Derived obj = new Test();
obj.getDetails();
}
}

a) Test class Derived class


b) Derived class Test class
c) Compilation error
d) Runtime error
Answers
1 d) include
2 b) run()
3 b) false
4 a) Object Oriented Programming
5 b) Inheritance
6 b) public abstract void method();
7 a) 30Hello
8 d)Static constructor
9 d) All of the above
10 A) int number;
11 D) No default value
12 B) start)(
13 D) Default (no modifier)
14 A) x > y ? x : y
15 A) A way to create new classes from existing classes
16 B) To call the constructor of a parent class
17 D) Pointer arithmetic
18 D)Hello1020
19 D) Java is a platform-independent language
20 C) java.util.ArrayList
21 D) Both A and C
22 B) The variable is immutable
23 B) Constructors do not have a return type
24 A) Using `try` and `catch` blocks
25 a) Test class Derived class

You might also like