Home / My courses / UGRD-CS6203-2313T / PRELIM EXAM / PRELIM EXAM
Started on Monday, 16 October 2023, 8:11 AM
State Finished
Completed on Monday, 16 October 2023, 9:38 AM
Time taken 1 hour 26 mins
Marks 50.00/50.00
Grade 100.00 out of 100.00
Question 1
Correct
Mark 1.00 out of 1.00
What is byte code in Java?
a. Code generated by a Java Virtual Machine
b. Name of Java source code file
c. Block of code written inside a class
d. Code generated by a Java compiler
Your answer is correct.
Question 2
Correct
Mark 1.00 out of 1.00
Which access type data gets derived as private member in derived class?
a. Public
b. Protected
c. Protected and Private
d. Private
Your answer is correct.
Question 3
Correct
Mark 1.00 out of 1.00
Which polymorphism behavior do you see in below class?
class Paint {
// all methods have same name
public void Color(int x) {}
public void Color(int x, int y) {}
public void Color(int x, int y, int z) {}
a. Method overloading
b. Run time polymorphism
c. Method overriding
d. Constructor overloading
Your answer is correct.
Question 4
Correct
Mark 1.00 out of 1.00
What is the type and value of the following expression? (Notice the integer division) -4 + 1/2 + 2*-3 + 5.0
a. double -4.5
b. int -5
c. double -5.0
d. int -4
Your answer is correct.
Question 5
Correct
Mark 1.00 out of 1.00
Which statement is not true in java language?
a. A public member of a class can be accessed in all the packages.
b. A protected member of a class can be accessed from its derived class.
c. A private member of a class cannot be accessed by the methods of the same class.
d. A private member of a class cannot be accessed from its derived class.
Your answer is correct.
Question 6
Correct
Mark 1.00 out of 1.00
Consider the following code fragment Rectangle r1 = new Rectangle(); r1.setColor(Color.blue); Rectangle r2 = r1; r2.setColor(Color.red);
After the above piece of code is executed, what are the colors of r1 and r2 (in this order)?
a. Color.blue Color.blue
b. Color.red Color.blue
c. Color.red Color.red
d. Color.blue Color.red
Your answer is correct.
Question 7
Correct
Mark 1.00 out of 1.00
Which of the following is TRUE?
a. A class has always a constructor (possibly automatically supplied by the java compiler).
b. int is the name of a class available in the package java.lang
c. Instance variable names may only contain letters and digits.
d. In java, an instance field declared public generates a compilation error.
Your answer is correct.
Question 8
Correct
Mark 1.00 out of 1.00
Which one of the following is not true?
a. A class containing abstract methods is called an abstract class.
b. An abstract class cannot have non-abstract methods.
c. Abstract methods should be implemented in the derived class.
d. A class must be qualified as ‘abstract’ class, if it contains one abstract method.
Your answer is correct.
Question 9
Correct
Mark 1.00 out of 1.00
The default value of a static integer variable of a class in Java is,
a. 1
b. 0
c. Null
d. Garbage value
Your answer is correct.
Question 10
Correct
Mark 1.00 out of 1.00
What is byte code in Java?
a. Code generated by a Java compiler
b. Block of code written inside a class
c. Name of Java source code file
d. Code generated by a Java Virtual Machine
Your answer is correct.
Question 11
Correct
Mark 1.00 out of 1.00
Which of these is not a bitwise operator?
a. |=' Operator
b. &=' Operator
c. &' Operator
d. <=' Operator
Your answer is correct.
Question 12
Correct
Mark 1.00 out of 1.00
Which of these have highest precedence?
a. *
b. >>
c. ++
d. ()
Your answer is correct.
Question 13
Correct
Mark 1.00 out of 1.00
To prevent any method from overriding, we declare the method as,
a. final
b. const
c. static
d. abstract
Your answer is correct.
Question 14
Correct
Mark 1.00 out of 1.00
Who is known as the father of Java Programming Language?
a. James Gosling
b. Charel Babbage
c. Blais Pascal
d. M. P Java
Your answer is correct.
Question 15
Correct
Mark 1.00 out of 1.00
In java control statements break, continue, return, try-catch-finally and assert belongs to?
a. Transfer statements
b. Loop Statements
c. Selection statements
d. Pause Statement
Your answer is correct.
Question 16
Correct
Mark 1.00 out of 1.00
Among these expressions, which is(are) of type String?
a. Both (A) and (B) above
b. "ab" + "cd"
c. "0"
d. '0'
Your answer is correct.
Question 17
Correct
Mark 1.00 out of 1.00
What is printed by the following statement? System.out.print("Hello,\nworld!");
a. Hello, world!
b. Hello, \nworld!
c. "Hello, \nworld!"
d. None of the above.
Your answer is correct.
Question 18
Correct
Mark 1.00 out of 1.00
What is the output of the following program: public class testmeth { static int i = 1; public static void main(String args[]) {
System.out.println(i+” , “); m(i); System.out.println(i); } public void m(int i) { i += 2; } }
a. 1 , 1
b. 1 , 0
c. 1,3
d. 3 , 1
Your answer is correct.
Question 19
Correct
Mark 1.00 out of 1.00
In java control statements break, continue, return, try-catch-finally and assert belongs to?
a. Selection statements
b. Loop Statements
c. Pause Statemen
d. Transfer statements
Your answer is correct.
Question 20
Correct
Mark 1.00 out of 1.00
The fields in an interface are implicitly specified as,
a. protected
b. both static and final
c. static only
d. private
Your answer is correct.
Question 21
Correct
Mark 1.00 out of 1.00
Which statement transfers execution to different parts of your code based on the value of an expression?
a. if-else-if
b. Switch
c. If
d. Nested-if
Your answer is correct.
Question 22
Correct
Mark 1.00 out of 1.00
Java language was initially called as ________
a. Oak
b. Pine
c. Sumatra
d. J++
Your answer is correct.
Question 23
Correct
Mark 1.00 out of 1.00
In Java code, the line that begins with /* and ends with */ is known as?
a. Multiline comment
b. None of these
c. Both A & B
d. Single line comment
Your answer is correct.
Question 24
Correct
Mark 1.00 out of 1.00
Multiple inheritance means,
a. more classes inheriting from more super classes
b. None of the above
c. one class inheriting from more super classes
d. more classes inheriting from one super class
Your answer is correct.
Question 25
Correct
Mark 1.00 out of 1.00
Which of the following are not Java keywords ?
a. case
b. double
c. switch
d. then
Your answer is correct.
Question 26
Correct
Mark 1.00 out of 1.00
Consider the following class definition: public class MyClass { private int value; public void setValue(int i){ /* code */ } // Other
methods... } The method setValue assigns the value of i to the instance field value. What could you write for the implementation of
setValue?
a. Both (A) and (B) and above
b. this.value = i;
c. value = i;
d. value == i;
Your answer is correct.
Question 27
Correct
Mark 1.00 out of 1.00
Which one is a template for creating different objects ?
a. A class
b. An Array
c. Interface
d. Method
Your answer is correct.
Question 28
Correct
Mark 1.00 out of 1.00
Data type long literals are appended by _____
a. Uppercase L
b. Lowercase L
c. Long
d. Both A and B
Your answer is correct.
Question 29
Correct
Mark 1.00 out of 1.00
Which variables are created when an object is created with the use of the keyword 'new' and destroyed when the object is destroyed?
a. Local variables
b. Static variables
c. Class Variables
d. Instance variables
Your answer is correct.
Question 30
Correct
Mark 1.00 out of 1.00
Consider the two methods (within the same class) public static int foo(int a, String s) { s = "Yellow"; a=a+2; return a; } public static void
bar() { int a=3; String s = "Blue"; a = foo(a,s); System.out.println("a="+a+" s="+s); } public static void main(String args[]) { bar(); } What is
printed on execution of these methods?
a. a = 3 s = Yellow
b. a = 5 s = Blue
c. a = 5 s = Yellow
d. a = 3 s = Blue
Your answer is correct.
Question 31
Correct
Mark 1.00 out of 1.00
What will be printed as the output of the following program? public class testincr { public static void main(String args[]) { int i = 0; i =
i++ + i; System.out.println("I = " +i); } }
a. I=3
b. I = 1
c. I=0
d. I = 2
Your answer is correct.
Question 32
Correct
Mark 1.00 out of 1.00
What is the full form of JVM ?
a. Java Very Small Machine
b. Java Verified Machine
c. Java Virtual Machine
d. Java Very Large Machine
Your answer is correct.
Question 33
Correct
Mark 1.00 out of 1.00
Which of the following could be written with little knowledge of java?
a. Java Servlets
b. Java Server Pages
c. Java Community Program
d. Common Gateway Interface
Your answer is correct.
Question 34
Correct
Mark 1.00 out of 1.00
Which type of function among the following shows polymorphism?
a. Inline function
b. Class member functions
c. Virtual function
d. Undefined functions
Your answer is correct.
Question 35
Correct
Mark 1.00 out of 1.00
Consider, public class MyClass { public MyClass(){/*code*/} // more code... } To instantiate MyClass, you would write?
a. MyClass mc = MyClass();
b. MyClass mc = MyClass;
c. MyClass mc = new MyClass;
d. MyClass mc = new MyClass();
Your answer is correct.
Question 36
Correct
Mark 1.00 out of 1.00
Which of the following variable declaration would NOT compile in a java program?
a. int var1;
b. int VAR;
c. int 1_var;
d. int var;
Your answer is correct.
Question 37
Correct
Mark 1.00 out of 1.00
Which of the following are not Java modifiers?
a. private
b. friendly
c. transient
d. public
Your answer is correct.
Question 38
Correct
Mark 1.00 out of 1.00
Which of the following is true?
a. A finally block is executed whether an exception is thrown or not.
b. A finally block is executed before the catch block but after the try block.
c. A finally block is executed, only if an exception occurs.
d. A finally block is executed, only after the catch block is executed.
Your answer is correct.
Question 39
Correct
Mark 1.00 out of 1.00
Division operator has ____ precedence over multiplication operator
a. None of These
b. Highest
c. Equal
d. Least
Your answer is correct.
Question 40
Correct
Mark 1.00 out of 1.00
Which of the following is not true?
a. An interface can extend another interface.
b. A class which is implementing an interface must implement all the methods of the interface.
c. An interface can implement another interface.
d. An interface is a solution for multiple inheritance in java.
Your answer is correct.
Question 41
Correct
Mark 1.00 out of 1.00
Which of these is returned by operator '&' ?
a. Boolean
b. Float
c. Character
d. Integer
Your answer is correct.
Question 42
Correct
Mark 1.00 out of 1.00
Which symbol is used to contain the values of automatically initialized arrays?
a. Comma
b. Braces
c. Parentheses
d. Brackets Brackets
Your answer is correct.
Question 43
Correct
Mark 1.00 out of 1.00
A constructor
a. Is used to create objects.
b. May be declared private
c. Must have the same name as the class it is declared within.
d. (a), (b) and (c) above.
Your answer is correct.
Question 44
Correct
Mark 1.00 out of 1.00
Which among the following can’t be used for polymorphism?
a. Constructor overloading
b. Member functions overloading
c. Static member functions
d. Predefined operator overloading
Your answer is correct.
Question 45
Correct
Mark 1.00 out of 1.00
Which programming language doesn’t support multiple inheritance?
a. Java
b. C and C++
c. Java and SmallTalk
d. C++ and Java
Your answer is correct.
Question 46
Correct
Mark 1.00 out of 1.00
Which among the following best defines single level inheritance?
a. A class inheriting a derived class
b. A class inheriting a base class
c. A class inheriting a nested class
d. A class which gets inherited by 2 classes
Your answer is correct.
Question 47
Correct
Mark 1.00 out of 1.00
What do you call the languages that support classes but not polymorphism?
a. Class based language
b. Procedure Oriented language
c. If classes are supported, polymorphism will always be supported
d. Object-based language
Your answer is correct.
Question 48
Correct
Mark 1.00 out of 1.00
Which one is true about a constructor ?
a. All of the above
b. A constructor is used to create objects
c. A constructor may be declared private
d. A constructor must have the same name as the class it is declared within
Your answer is correct.
Question 49
Correct
Mark 1.00 out of 1.00
Which provides runtime environment for java byte code to be executed?
a. JAVAC
b. JRE
c. JVM
d. JDH
Your answer is correct.
Question 50
Correct
Mark 1.00 out of 1.00
Modulus operator (%) can be applied to which of these?
a. None of These
b. Both A and B
c. Integers
d. Floating - point numbers
Your answer is correct.
Jump to...
Prelim Lab Exam ►