Alien head

Computer Basics - 1

Description: Computer Basics Mix Test - 1
Number of Questions: 27
Created by:
Tags: Computer Basics Mix Test - 1 Computer Basics
Attempted 0/27 Correct 0 Score 0

Which of the following statements regarding Math class is/are true?

i. Math class cannot be instantiated and all the methods are static.
ii. All the methods are non-static in Math class and so, the Math class can be instantiated.
iii. Constructor is always public in Math class.
iv. Constructor is always private in Math class.

  1. i. and iv. are true

  2. i. and iii. are true

  3. ii. and iii. are true

  4. ii. and iv. are true


Correct Option: A
Explanation:

This answer is correct. Math class has all the methods as static and it can be called without instantiating. Also, the constructor defined for Math class is declared as private.

Which of the following statements is/are true?

i. Primitive data types are passed by value.
ii. Java only supports pass by value.
iii. Java only supports pass by reference.
iv. Primitive data types are passed by reference.

  1. Both i and iii. are true

  2. Both ii. and iv. are true

  3. Both i. and ii. are true

  4. Both iii. and iv. are true


Correct Option: C
Explanation:

This answer is correct. Java only supports pass by value not pass by reference. The primitive data types are passed by value. Also, since no object defined for primitive types, primitive data types are passed only by value.

Which of the following statements is/are true?

i. Linked-List is sequential accessing.
ii. Linked-List is random accessing.
iii. Array-List is random accessing.
iv. Array-List is sequential accessing.

  1. i. and iv. both are true

  2. i. and iii. both are true

  3. ii. and iii. both are true

  4. ii. and iv. both are true


Correct Option: B
Explanation:

This answer is correct. Linked-List is sequential accessing. It means that the data which is added to Linked-List will be retained in the order they are inserted whereas Array-List is random accessing. It means that the data which is added to Array-List will not be retained in the order they are inserted.

Which of the following statements is correct?

i. Final methods can be overridden
ii. Final methods cannot be overridden
iii. Final fields are constants
iv. Final variables can be changed

  1. i. and iv. both are true

  2. i. and iii. both are true

  3. ii. and iv. both are true

  4. ii. and iii. both are true


Correct Option: D
Explanation:

This answer is correct. Both the options are correct. Final methods cannot be overridden. Similarly, variables declared as final cannot be changed and are always constants.

Which of the following statements is/are true?

i. A local inner class may be final or abstract
ii. A local inner class should not be final or abstract
iii. A local inner class can only be static
iv. A local inner class can have any modifier

  1. Only i.is true

  2. Only ii. is true

  3. Only iii.is true

  4. Only iv. is true


Correct Option: A
Explanation:

This answer is correct. A local inner class may only be final or abstract and cannot be static or any other modifier.

Which of the following is true about automatic type conversion in java?

i. Both the variable types should be compatible
ii. The destination type is smaller than the source type
iii. Both the variables can have any data types
iv. The destination type is larger than the source type

  1. i. and ii both are correct.

  2. i. and iv. both are correct.

  3. ii. and iii. both are correct.

  4. ii. only is correct


Correct Option: B
Explanation:

This answer is correct. When the automatic type conversion has to happen between two variables, then both the data types should be compatible and also the destination type should be larger than the source type.

Which of the following is true?

i. All transcendental math functions like sin(), cos() etc return float values.
ii. All transcendental math functions like sin(), cos() etc return double values.
iii. All transcendental math functions like sin(), cos() etc return int values.
iv. All transcendental math functions like sin(), cos() etc return long values.

  1. i. is only correct

  2. ii. is only correct

  3. iii. is only correct

  4. iv. is only correct


Correct Option: B
Explanation:

This answer is correct. Java returns double values because double precision will be faster than the single precision and also to optimize the high-speed math calculations.

Which of the following is true?

i. Java doesnt support unsigned, positive only integers
ii. Java doesnt support signed, positive only integers
iii. Java doesnt support unsigned negative only integers
iv. Java doesnt support signed negative only integers

  1. i. is correct

  2. ii. is correct

  3. iii. is correct

  4. iv. is correct


Correct Option: A
Explanation:

Java supports four integer types namely byte, short, int and long. All these are signed, positive and negative values. But Java doesnt support unsigned, positive integers.

Which keyword is used for a variable, which will change the value irrespective of the thread that is being called?

  1. Transient

  2. Volatile

  3. Synchronized

  4. Native


Correct Option: B
Explanation:

The answer is correct. This keyword is used for any variable when the value needs to be changed irrespective of the thread being called.

Which of the following is true?

i. Only byte value used in the expression will be promoted to int when the expression is evaluated.
ii. Only short value used in the expression will be promoted to int when the expression is evaluated.
iii. Both byte and short value used in the expression will be promoted to int when the expression is evaluated.
iv.Neither byte nor short value used in the expression will be promoted to int when the expression is evaluated.

  1. i. is correct

  2. ii. is correct

  3. iii. is correct

  4. iv. is correct


Correct Option: C
Explanation:

This answer is correct. Byte and short value both will be promoted to int when the expression is evaluated. So, the answer is correct.

How do you get the size of the String in Java?

  1. Length

  2. Length()

  3. Size()

  4. Get length()


Correct Option: B
Explanation:

This answer is correct.This method is used to get the size of the String in Java.

Which of the following is true?

i. A nested class has access to the members of its outer class.
ii. A nested class will never have access to the members of its outer class.
iii. A inner class is a non-static nested class.
iv. A inner class is a static nested class.

  1. i. and iii both are correct

  2. i. and iv. both are correct

  3. ii. and iii. both are correct

  4. ii. and iv. both are correct


Correct Option: A
Explanation:

This answer is correct. A nested class will have access to the members in the outer class including its private members. Also an inner class is always a non-static class and it has access to all the other non-static members of the outer class.

What is the constant variable which is not part of Fload and Double wrapper classes in Java 6?

  1. MAX_VALUE

  2. MIN_VALUE

  3. MAX_NORMAL

  4. MIN_NORMAL


Correct Option: C
Explanation:

This answer is correct because this constant variable is not part of Float and Double wrapper classes.

Which method is not present in String Buffer?

  1. Insert(int index, string str)

  2. Reverse()

  3. Format(string str)

  4. Delete(int startIndex, int endIndex)


Correct Option: C
Explanation:

This answer is correct because format(string str) does not exist in String Buffer class.

Which of the following options is correct?

i. The Serializable interface has 0 methods
ii. The Serializable interface has 1 method
iii. The Serializable interface has 2 methods
iv. The Serializable interface has 3 methods

  1. i. is true

  2. ii. is true

  3. iii. is true

  4. iv. is true


Correct Option: A
Explanation:

This answer is correct because Serializable interface is a marker interface and does not have any methods. This interface when implemented, tells the object serializable tools whether the class is serializable or not.

Which method is not present in Throwable class?

  1. FillIn Stack Trace()

  2. Get cause()

  3. Set cause (Throwable)

  4. Set StackTrace(StackTrace elements[])


Correct Option: C
Explanation:

This answer is correct.This method does not exists in Throwable class.

What is true from the following options?

i. The Reader/Writer class is character oriented.
ii. The Reader/Writer class is byte oriented.
iii. The InputStream/OutputStream class is character oriented.
iv. The InputStream/OutputStream class is byte oriented.

  1. i. and iii. are true

  2. i. and iv. are true

  3. ii. and iii. are true

  4. ii. and iv. are true.


Correct Option: B
Explanation:

The answer is correct.The Reader/Writer class is used when any manipulation needs to be done on characters whereas InputStream/OutputStream class is used when any manipulation needs to be done on bytes.

Which is true regarding the following options?

i. If the value of the object is changed, then we call it an immutable object
ii. If the value of the object is not changed, then we call it an immutable object
iii. If the object cannot be instantiated, then we call it an immutable object
iii. If the object can be instantiated, then we call it an immutable object

  1. i. is true

  2. ii. is true

  3. iii. is true

  4. iv. is true


Correct Option: B
Explanation:

This answer is correct. if the value of the object is not changed, then the object is called an immutable object else it is called a mutable object.

Which of the following options is true?

i. When an object invokes yield() method, it will not return to ready state.
ii. When an object invokes yield() method, it will return to ready state.
iii. When an object invokes sleep() method, it will return to ready state.
iv. When an object invokes sleep() method, it will not return to ready state.

  1. i. and iii. are true

  2. i. and iv. are true

  3. ii. and iii. are true

  4. ii. and iv. are true


Correct Option: D
Explanation:

This answer is correct. When an object invokes yield() method, the object will be ready to perform the next action and so it will be returned to the ready state. When the object calls sleep() method, it will not execute any further action and so it will not be ready to perform next action.

Pick out what is true from the following options?
i. Object instantiated from String Buffer is thread-safe.
ii. Object instantiated from String Builder is thread-safe.
iii. String Buffer has high and fast performance.
iv. String Builder has high and fast performance.

  1. i. and iii. are true.

  2. i. and iv. are true

  3. ii. and iii. are true.

  4. ii. and iv. are true.


Correct Option: B
Explanation:

This answer is correct. String Buffer is synchronized or thread-safe and String Builder has higher performance compared to String Buffer.

Which of the following is not a method of Object class?

  1. finalize()

  2. wait()

  3. sleep(long millis)

  4. notify()


Correct Option: C
Explanation:

This answer is correct because this method is not a part of Object class.This method is present in Thread class as a static method.

What of the following statements is true about NoSuchMethodException?

i. NoSuchMethodException is caused when the method cannot be called.
ii. NoSuchMethodException is caused when the method does not exist.
iii. NoSuchMethodException is a Checked Exception.
iv. NoSuchMethodException is a Unchecked Exception.

  1. i. and iv. are true

  2. i. and iii. are true

  3. ii. and iii. are true

  4. ii. and iv. are true


Correct Option: C
Explanation:

This answer is correct. NoSuchMethodException is caused when the method does not exist. NoSuchMethodException is a Checked Exception.

Which method is not final in Object class?

  1. getClass()

  2. notify()

  3. notify all()

  4. hashCode()


Correct Option: D
Explanation:

This answer is correct. GetClass(), notify(), notify all() and wait() methods in Object class are declared as final. All other methods can be overridden. HashCode() can be overridden in any class.

Which of the following options is true?

i. Float and Double classes have only a non-static method i.e. Nan() method.

ii. Float and Double classes have only one static method i.e. Nan() method.

iii. Float and Double classes have one static method i.e. Nan() method, and one non-static method i.e. Nan() method.

iv. Float and Double classes does not have any Nan() method.

  1. i

  2. ii

  3. iii

  4. iv


Correct Option: C
Explanation:

This answer is correct. Float and Double classes has a static method is Nan() method taking  float value if it is called from Float class and takes double value if it is called from Double class. Also, Float and Double classes has a non-static method is Nan() which will return true if the invoking object contains a value that is not a number. Else it returns false.

Which of the following is true about ClassNotFoundException?

i. ClassNotFoundException is caused when the class is not found.
ii. ClassNotFoundException is caused when the class cannot instantiated.
iii. ClassNotFoundException is a Checked Exception.
iv. ClassNotFoundException is a Unchecked Exception.

  1. i. and iii. are true

  2. i. and iv. are true

  3. ii. and iii. are true

  4. ii. and iv. are true


Correct Option: A
Explanation:

This answer is correct. ClassNotFoundException is caused when the class is not found and it is a checked exception.

Which is true from the following options?

i. Constructors should not have the return type but the methods may or may not have a return type
ii. Constructors must have the return type but the methods may or may not have return type
iii. Constructors may or may not have the same name as that of the class name but methods must have the same name as that of the class name.
iv. Constructors must have the same name as that of the class name, but methods may or may not have the same name as that of the class name

  1. ii. and iii. are true

  2. ii. and iv. are true

  3. i. and iii. are true

  4. i. and iv. are true


Correct Option: D
Explanation:

This answer is correct. Constructors never have return type whereas other methods may or may not have return types. Also, Constructors must have the same name as that of the class name and the other method names may or may not have the same name as that of the class name.

Which of the following options is true?

i. Float and Double classes have only one non-static method i.e. Infinite() method.

ii. Float and Double classes have one static method i.e. Infinite() method, and one non-static method i.e. Infinite() method.

iii. Float and Double classes have only one static method is Infinite() method.

iv. Float and Double classes does not have any Infinite() method.

  1. i

  2. ii

  3. iii

  4. iv


Correct Option: B
Explanation:

This answer is correct. Float and Double classes has one static isInfinite() method and a non-static method is Infinite() method.The non-static method takes float number when invoked from Float class and will return true if the invoking object contains an infinite value.The non-static method takes double number when invoked from Double class and will return true if the invoking object contains an infinite value whereas static method will return true if the number specified is an infinte value in both the classes else return false.

+ View questions