0% found this document useful (0 votes)
3 views

CE 277 - Programming with Java

This document is an examination paper for the course CE 277: Programming with Java at the University of Mines and Technology, Tarkwa. It consists of multiple-choice questions covering various Java programming concepts, including object-oriented programming principles, Java syntax, and code snippets. The exam is scheduled for April 2024 and is designed for CE II students, with a total of 50 questions.

Uploaded by

payloadthirteen
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)
3 views

CE 277 - Programming with Java

This document is an examination paper for the course CE 277: Programming with Java at the University of Mines and Technology, Tarkwa. It consists of multiple-choice questions covering various Java programming concepts, including object-oriented programming principles, Java syntax, and code snippets. The exam is scheduled for April 2024 and is designed for CE II students, with a total of 50 questions.

Uploaded by

payloadthirteen
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/ 9

UNIVERSITY OF MINES AND TECHNOLOGY, TARKWA

FIRST SEMESTER EXAMINATION, APRIL 2024


COURSE NO: CE 277
COURSE NAME: PROGRAMMING WITH JAVA
CLASS: CE II TIME: 1 Hour

LNUGS-UMAT SRID
Name: __________________________________________ Index Number: _______________
• Answer all questions in Section A by circling the correct answer
• Do not take any paper out

SECTION A: OBJECTIVES (25 MARKS)

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

3. Java language was initially called as


7. The State of an object represents
________
the………………...
a. Sumatra
a. Data (value)
b. J++
b. Where it was initialized
c. Oak
c. Type of object
d. Pine
d. None of the above
4. The following are OOP principles except
a. Encapsulation
b. Inheritance
c. Subtraction
d. None of the above

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(){ }

9. Which statement is true regarding an 12. A package is a collection of


object? a. Classes
a. An object is an instance of a class b. Interfaces
b. An object is a variable c. Editing tools
c. An object is a reference to an d. Classes and interfaces
attribute
d. An object is not an instance of a 13. URL stands for
class. a. Universal reader locator
b. Universal reform loader
10. In OOP, new classes can be defined by c. Uniform resource locator
extending existing classes. This is an d. Uniform resource loader
example of:
a. Encapsulation 14. Which one of these is a valid method
b. Interface declaration?
c. Composition a. void method1
d. Inheritance b. void method2()
c. void method3(void)
d. method4()

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;
}

a. Field i is accessible in all classes in other packages\


b. Field j is accessible in all classes in other packages
c. Field k is accessible in all classes in other packages\
d. Field l is accessible in all classes in other packages

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

26. In a Java code, the line that begins with


/* and ends with */ is known as?
a. Multiline comment
b. Single line comment
c. Both A & B
d. None of these

Use the following snippet of code to answer questions 27 – 30


public class StudentDetails {
public void StudentAge() {
int age = 0;
age = age + 5;
System.out.println("Student age is : " + age);
}
public static void main(String args[]) {
StudentDetails obj = new StudentDetails();
obj.StudentAge(); } }

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

Use the following code to answer question 32 - 33


class Adder{
static int add(int a,int b){return a+b;}
static int add(int a,int b,int c){return a+b+c;}
}
class Test1{
public static void main(String[] args){
System.out.println(Adder.add(11,11));
System.out.println(Adder.add(11,11,11));
}}

32. Which of the following is done in the


code above? 33. What will be the output of the code?
a. Method Duplication a. 11, 11 & 11, 11, 11
b. Method Overloading b. 1111, 111111
c. Method Overriding c. 55
d. Method Multiplication d. 22, 33

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

36. Which of the following is mainly used to develop desktop applications?


a. Java EE
b. Java SE
c. Java ME
d. Java FX

Analyze the following code and answer the questions 37- 39


class Marks {
int engMarks;
int mathsMarks;
}
class MarksDemo {
public static String name = "Harsh";
public static void main(String args[ ])
{
// first object
Marks obj1 = new Marks();
obj1.engMarks = 50;
obj1.mathsMarks = 80;

// 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);

// displaying marks for second object


System.out.println("Marks for second object:");
System.out.println(obj2.engMarks);
System.out.println(obj2.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

You might also like