CE 277 - Programming with Java
CE 277 - Programming with Java
LNUGS-UMAT SRID
Name: __________________________________________ Index Number: _______________
• Answer all questions in Section A by circling the correct answer
• Do not take any paper out
1. When one object acquires all the 5. The new keyword is used to allocate
properties and behaviours of a parent memory at…………...
object, it is known as a. Code time
a. Polymorphism b. Compile time
b. Inheritance c. Runtime
c. Property Acquiring d. Processing time
d. Abstraction
6. In Java, Objects can be initialized by all
2. Java is a................... language the following except
a. Weakly typed a. By reference variable
b. Strongly typed b. By method
c. Moderate typed c. By constructor
d. None of these d. By child class
Page 1 of 8
8. A process that involves focusing on the 11. Given a class named Student, which of
important characteristics of an object is the following is a valid constructor
known as: declaration for the class?
a. Encapsulation a. Student (student s) { }
b. Polymorphism b. Private final student ( ) { }
c. Abstraction c. Void student ( ) { }
d. Inheritance d. Static void student(){ }
Page 2 of 8
LNUGS-UMAT SRID
15. Given the following definition of a class, which fields are accessible from outside the
package com.corporation.project?
package com.corporation.project;
public class MyClass
{
int i;
public int j;
protected int k;
private int l;
}
16. Who is known as father of Java 18. What is byte code in Java?
Programming Language? a. Code generated by a Java compiler
a. James Gosling b. Code generated by a Java Virtual
b. M. P Java Machine
c. Charel Babbage c. Name of Java source code file
d. Blais Pascal d. Block of code written inside a class
17. Which of the following provides runtime 19. Which one is a template for creating
environment for java byte code to be different objects?
executed? a. An Array
a. JDK b. A class
b. JVM c. Interface
c. JRE d. Method
d. JAVAC
Page 3 of 8
20. Which of these has highest precedence? 23. Which variables are created when an
a. () object is created with the use of the
b. ++ keyword 'new' and destroyed when the
c. * object is destroyed?
d. >> a. Local variables
b. Instance variables
21. Which of these is returned by Greater
c. Class Variables
Than, Less Than and Equal To (i.e.
d. Static variables
Relational) operator?
a. Float
24. Modulus operator (%) can be applied to
b. Integer
which of these?
c. Boolean
a. Integers
d. Double
b. Floating - point numbers
c. Both A and B
22. Which statement transfers execution to
d. None of These
different parts of your code based on the
value of an expression?
25. What is the full form of JVM?
a. If
a. Java Very Large Machine
b. Switch
b. Java Verified Machine
c. Nested-if
c. Java Very Small Machine
d. if-else-if
d. Java Virtual Machine
Page 4 of 8
LNUGS-UMAT SRID
27. In the above code, the variable ‘age’ 29. What value will ‘obj.StudentAge()’
is a ……………………… hold?
a. Local variable a. 0
b. Unique variable b. It depends on the student’s age
c. Instance variable c. 5
d. Static variable d. None of the above
28. From the first method the value of 30. In the above code, there is/are
‘age’ will be ………………...method(s).
……………………………. a. 1
a. 10 b. 2
b. 5 c. 3
c. 0 d. 4
d. None of the above
31. If a class has multiple methods
having same name but different in
parameters, it is known
as ………………………………...
a. Method Duplication
b. Method Overloading
c. Method Overriding
d. Method Multiplication
Page 5 of 8
34. If subclass (child class) has the same method as declared in the parent class, it is known
as……………………………...
a. Method Duplication
b. Method Overloading
c. Method Overriding
d. Method Multiplication
35. Which of the following is mainly used to develop web and enterprise applications?
a. Java EE
b. Java SE
c. Java ME
d. Java FX
// second object
Marks obj2 = new Marks();
obj2.engMarks = 80;
obj2.mathsMarks = 60;
// displaying marks for first object
Page 6 of 8
System.out.println("Marks for first object:");
System.out.println(obj1.engMarks);
System.out.println(obj1.mathsMarks);
37. The variables declared in ‘class 40. One of the following is not a type of
Marks’ are examples of programming language…………….
a. Local variables a. Structured
b. Unique variable
b. Semi structured
c. Instance Variables
d. Static variables c. Unstructured
d. Object Oriented
38. How many static variables exist in
the code? 41. What is known as the classes that
a. 0 extend Throwable class except
b. 1 RuntimeException and Error?
c. 2 a. Checked Exception
d. 3 b. Unchecked Exception
c. Error
39. Which of the following methods d. None of the above
contains a static variable?
a. Marks 42. JRE stands for……………………….
b. MarksDemo1 a. Java Reserved Environment
c. Main b. Java Resources Encapsulation
d. None of the above c. Java Runtime Environment
d. Java Runtime Enjoyment
LNUGS-UMAT SRID
Page 7 of 8
43. JDK stands for 47. Single line comments are written in
………………………………. Java using
a. Java Development Kit a. /* */
b. Java Development Kite
b. //
c. Java Development Knit
d. Java Delvik Kit c. // //
d. /
44. Which of the following are object
Consider the following code and answer
oriented languages?
questions 48 to 50
i. Java
ii. Cobol class Simple{
public static void main(String[] args){
iii. C#
iv. C++ float f=10.5f;
v. C int a=f;
int a=(int)f;
a. I, III, and IV only
System.out.println(f);
b. I, III, and V only System.out.println(a);
c. I, III, IV, and V only }}
d. I and IV only
48. What will happen on the fourth line?
a. Nothing
45. Which of the following is used for b. Overriding
c. Error
multi-line commenting in JAVA?
d. A pause
a. ///
b. */ /* 49. What will ‘System.out.println(f)’
return?
c. /* /*
a. Error
d. /* */ b. 10.5
46. Assuming that + and * are arithmetic c. 10
operators (addition and d. 10.0
multiplication), to what does the
expression 2 + 4 * 5 + 1 evaluate? 50. What will ‘System.out.println(a)’
a. 36 return?
b. 31 a. Error
c. 26 b. 10.5
d. 23 c. 10
d. 10
Page 8 of 8
LNUGS-UMAT SRID
Page 9 of 8