Choose The Best Answer From The Given Alternatives: 1. Increment 2. Main Args 3. 4. G 5. - . G 6. 7. C. 24 D. 25 7
Choose The Best Answer From The Given Alternatives: 1. Increment 2. Main Args 3. 4. G 5. - . G 6. 7. C. 24 D. 25 7
Choose The Best Answer From The Given Alternatives: 1. Increment 2. Main Args 3. 4. G 5. - . G 6. 7. C. 24 D. 25 7
1. What does the phrase “Java is Write once and run anywhere” represent?
A. Java supports object-oriented coding
B. Java is platform independent
C. Java is being used anywhere
D. Java is robust
2. Which of the following command(s) do we use to compile and execute java program from the
console (command) prompt respectively?
A. java, javac C. javac, java
B. java, execute D. javac, execute
3. which of the following looping statement executes the body of the program before checking the
condition?
A. While loop C. For loop
B. Do… while D. Switch
4. Which of the following is the file extension of the byte code?
A. .java C. .exe
B. .class D. .byte
5. Which of the following is the correct syntax for initializing constant number in java?
A. Data type CONSTANTNAME=Value;
B. Data type final CONSTANTNAME=Value;
C. final data type CONSTANTNAME=Value;
D. final CONSTANTNAME=Value;
6. What will be the output of the following java code?
1. class increment {
2. public static void main(String args[])
3. {
4. int g = 3;
5. System.out.print(++g * 8);
6. }
7. }
A. 32 C. 24
B. 33 D. 25
7. Which of the following are invalid identifiers?
A. _helloworld C. Special$value
B. hIghValue D. %test
8. What is the output of the following program?
A. 12 C. 10
B. 11 D. Compilation Error
9. What will be the value of “X” after the following code is executed?
A. -2 D. 1
B. -1 E. 2
C. 0
short k=1;
k += 2;
System.out.println(k);
A. 1
B. 2
C. 3
D. Compiler error about Type Casting
11. What is the output of the Java code snippet?
A. 2 20 3 C. 2 10 5
B. 2 20 5 D. -2 20 3
12. Which is the arithmetic operator in Java that gives the Remainder of Division?
A. / C. %
B. @ D. &
13. Between Postfix and Prefix arithmetic operators in Java, which operators have more priority?
A. Postfix operators have more priority than Prefix operators
B. Prefix operators have more priority than Postfix operators
C. Both Prefix and Postfix operators have equal priority
D. None of the above
14. Among the operator groups (++, --) and (+, -, *, /, %) in Java, which group has higher priority?
A. (++, --) group has higher priority than (+, -, *, /, %) group
B. (++, --) group has lower priority than (+, -, *, /, %) group
C. (++, --) group and (+, -, *, /, %) group have equal priority
D. None of the above
15. Boolean logical operators in Java work with?
A. true/false boolean data
B. 1 and 0 of individual Bits
C. characters of a String
D. None of the above
16. What is the input for Logical Operators?
A. 1 and 0
B. true / false
C. char / String
D. None of the above
17. Which is the Logical operator in Java that works with a Single Operand?
A. Logical AND
B. Logical OR
C. Logical Exclusive OR
D. Logical NOT
18. Which among the following is a Short Circuit AND operator?
A. &
B. &&
C. |
D. ||
19. Which of the following can be operands of arithmetic operators?
A. Characters
B. Boolean
C. Numeric
D. Both Numeric & Characters
20. Modulus operator, %, can be applied to which of these?
A. Both Integers and floating - point numbers
B. Integers
C. Floating - point numbers
D. None of the mentioned
21. Evaluate the value of the expression?
6 - 2 + 10 % 4 + 7
A. 14
B. 12
C. 13
D. 10
22. When does method overloading is determined?
A. At run time
B. At compile time
C. At coding time
D. At execution time
23. Which concept of Java is a way of converting real world objects in terms of class?
A. Polymorphism
B. Encapsulation
C. Abstraction
D. Inheritance
24. Which concept of Java is achieved by combining methods and attribute into a class?
A. Encapsulation
B. Inheritance
C. Polymorphism
D. Abstraction
25. What is it called if an object has its own lifecycle and there is no owner?
A. Aggregation
B. Composition
C. Encapsulation
D. Association
26. What is it called where child object gets killed if parent object is killed?
A. Aggregation
B. Composition
C. Encapsulation
D. Association
27. What is it called where object has its own lifecycle and child object cannot belong to another parent
object?
A. Aggregation
B. Composition
C. Encapsulation
D. Association
28. Method overriding is combination of inheritance and polymorphism?
A. True
B. false
29. Encapsulation concept in java is
A. method hiding
B. Hiding constructor
C. Hiding complexity
D. None of the above
30. Runtime polymorphism feature in java is
A. method overriding
B. method overloading
C. operator overloading
D. constructor overloading
31. Which of the following is a type of polymorphism in Java?
A. Multiple polymorphism
B. Compile time polymorphism
C. Multilevel polymorphism
D. Execution time polymorphism
32. Which concept of Java is achieved by combining methods and attribute into a class?
A. Inheritance
B. Polymorphism
C. Encapsulation
D. Abstraction
33. Which feature of OOPS derives the class from another class?
A. Inheritance
B. Data hiding
C. Encapsulation
D. Polymorphism
34. Which two features of object-oriented programming are the same?
A. Abstraction and Polymorphism features are the same
B. Inheritance and Encapsulation features are the same
C. Encapsulation and Polymorphism features are the same
D. Encapsulation and Abstraction
35. Which of this keyword must be used to inherit a class?
A. Super
B. This
C. Extent
D. extends
36. A class member declared protected becomes a member of subclass of which type?
A. public member
B. private member
C. protected member
D. static member
37. Which of these is correct way of inheriting class A by class B?
A. class B + class A {}
B. class B inherits class A {}
C. class B extends A {}
D. class B extends class A {}
38. Inheritance means
A. Sub class extends Base class
B. Sub class extends super class
C. Sub class create object of super class
D. All of the above
39. What type of inheritance does Java have?
A. Single Inheritance
B. Double Inheritance
C. Multiple Inheritance
D. Class Inheritance
40. Which of these keywords is used to refer to member of base class from a sub class?
A. Super
B. Upper
C. This
D. implements
41. The super keyword is similar to _________ keyword.
A. Construct
B. this
C. class
D. extends
42. Which polymorphism concept is applied to inheritance relationship in java programming?
A. Method overloading
B. Constructor overloading
C. Method overriding
D. None
43. Which feature comes under compile time polymorphism?
A. Method overloading
B. Constructor overloading
C. Method overriding
D. Both A and B
E. Bothe A and C
44. The ability to define more than one function with the same name is called?
A. Inheritance
B. Encapsulation
C. Polymorphism
D. Abstraction
45. If same message is passed to objects of several different classes and all of those can respond in a
different way, what is this feature called?
A. Inheritance
B. Overloading
C. Polymorphism
D. Overriding
46. Which one is the best description of polymorphism?
A. It is the ability for undefined message/data to be processed in at least one way
B. It is the ability for a message/data to be processed in more than one form
C. It is the ability for many messages/data to be processed in many ways
D. none of these
47. Which of these keywords are used to define an abstract class?
A. abst
B. abstract
C. Abstract
D. abstract class
48. Which of these is not a correct statement?
A. Every class containing abstract method must be declared abstract
B. Abstract class defines only the structure of the class not its implementation
C. Abstract class can be initiated by new operator
D. Abstract class can be inherited
49. Which of these packages contains abstract keyword?
A. java.lang
B. java.util
C. java.io
D. java.system
50. Which among the following best describes encapsulation?
A. It is a way of combining various data members into a single unit
B. It is a way of combining various member functions into a single unit
C. It is a way of combining various data members and member functions into a single unit
which can operate on any data
D. It is a way of combining various data members and member functions that operate on
those data members into a single unit
51. If data members are private, what can we do to access them from the class object?
A. Create public member functions to access those data members
B. Create private member functions to access those data members
C. Create protected member functions to access those data members
D. Private data members can never be accessed from outside the class