1.
Which is a reserved word in the Java programming language?
Correct Answer
D. Native
Explanation
"native" is a reserved word in the Java programming language. In Java, reserved words are predefined keywords that have specific meanings and cannot be used as identifiers or variable names. The "native" keyword is used to indicate that a method is implemented in a language other than Java, typically in a platform-specific manner.
2.
From any non-sub-class Class outside the package, which access is possible?
Correct Answer
A. Public
Explanation
From any non-sub-class Class outside the package, the access that is possible is public. This means that any class outside the package can access the public members (variables, methods, etc.) of the non-sub-class Class. Public access allows for the widest accessibility and is not restricted to any specific class or package.
3.
What will be the output if you execute the following java code? import java.lang.*; class firstapp { static() { System.out.println(“Hello world”); } }
Correct Answer
D. Hello world with a warning message
Explanation
The code provided is attempting to define a static method in the class "firstapp". However, the method name is missing, which results in a compilation error. The correct syntax for defining a static method is "static void methodName()". Therefore, the correct answer is "Compilation error".
4.
Public class Test{} What is the prototype of the default constructor?
Correct Answer
A. Test()
Explanation
The prototype of the default constructor for the given class "Test" is "Test()". This is because the default constructor has the same name as the class and does not take any parameters.
5.
Which will legally declare, construct, and initialize an array?
Correct Answer
D. Int mylist[]={4,6,9};
Explanation
The correct answer is "int mylist[]={4,6,9};" because it is the only option that uses the correct syntax to declare, construct, and initialize an array. The other options either use incorrect syntax or do not properly initialize the array.
6.
Which design model lies behind the concept of object oriented programming?
Correct Answer
B. Bottom-up design
Explanation
The design model that lies behind the concept of object-oriented programming is bottom-up design. This approach involves breaking down a problem into smaller, more manageable components or objects, and then gradually building up the overall solution by combining these objects. It emphasizes starting with the details and gradually constructing the larger system. This contrasts with top-down design, which starts with the overall structure and breaks it down into smaller components.
7.
Which of the following is an object based language (OBL) ?
Correct Answer
C. Java Script
Explanation
JavaScript is an object-based language because it uses objects to represent and manipulate data. It supports object-oriented programming concepts such as inheritance and encapsulation. Objects in JavaScript are instances of classes, and they can have properties and methods. JavaScript also has a prototype-based inheritance model, where objects can inherit properties and methods from other objects. This makes JavaScript a suitable choice for building interactive web applications that require dynamic behavior and manipulation of objects.
8.
In OOPs which mechanism binds data and function together ?
Correct Answer
B. Encapsulation
Explanation
Encapsulation is the mechanism in Object-Oriented Programming (OOP) that binds data and functions together. It allows the data to be hidden and accessed only through the functions defined within the class. This helps in achieving data abstraction and ensures that the data is accessed and modified in a controlled manner. Encapsulation also provides data security and helps in maintaining the integrity of the object's state.
9.
The Scanner class defined in which package?
Correct Answer
A. Utility
Explanation
The correct answer is utility. The Scanner class is defined in the utility package in Java. This package contains various utility classes and interfaces that provide useful functions for input, output, and other general purposes. The Scanner class specifically is used for reading input from different sources, such as the keyboard or a file.
10.
Java is pure object oriented programming language because
Correct Answer
C. A single line of code cannot go outside from the class
Explanation
Java is considered a pure object-oriented programming language because it enforces the rule that a single line of code cannot go outside of a class. In Java, all code must be written within a class, and objects are created from these classes. This encapsulation ensures that all code is organized and structured within classes, promoting modularity and reusability. Additionally, Java's platform independence and ability to be both compiled and interpreted further solidify its status as a pure object-oriented language.
11.
In Java >>> operator is called
Correct Answer
B. Right shift with zero fill
Explanation
The ">>>" operator in Java is known as the right shift with zero fill operator. This operator shifts the bits of a number to the right by a specified number of positions, and fills the leftmost positions with zeros. Unlike the regular right shift operator (>>), the zero fill operator does not preserve the sign bit, meaning that it treats the number as an unsigned value.
12.
To check which object is of which class, which of the following is used
Correct Answer
C. Instanceof
Explanation
The keyword "instanceof" is used to check if an object is an instance of a particular class or implements a specific interface. It returns true if the object is an instance of the class or a subclass of it, or if it implements the interface. In this case, "instanceof" is the correct answer because it is specifically used for determining the class of an object. The other options, sizeof and comma, are not related to checking the class of an object.
13.
Which conditional statement always returns true value?
Correct Answer
B. If(a=0)
Explanation
The correct answer is "if(a=0)". This is because the single equals sign (=) is an assignment operator, not a comparison operator. Therefore, the statement "if(a=0)" will always assign the value 0 to the variable "a" and then evaluate the result as true.
14.
Array subscript in Java always starts at
Correct Answer
B. 1
Explanation
In Java, array subscripts always start at 0. This means that the first element of an array is accessed using the subscript 0. Therefore, the correct answer is 0.
15.
This reference is built-in reference can only used within
Correct Answer
B. Non-static function of the class
Explanation
The reference being referred to in the question is a "built-in reference," which suggests that it is a reference to a built-in object or feature within the programming language. The answer states that this built-in reference can only be used within a non-static function of the class. This implies that the built-in reference has certain limitations or restrictions, and it can only be accessed or utilized within a specific type of function in the class.
16.
Object communicate with each other by sending messages in the form of
Correct Answer
C. Functions
Explanation
Objects communicate with each other by sending messages in the form of functions. Functions are a way for objects to interact with each other and perform specific actions. They can be called by one object and executed by another, allowing for communication and collaboration between different objects in a program. Through the use of functions, objects can pass data, trigger actions, and respond to events, enabling them to work together to achieve a desired outcome.
17.
Data is given less importance in
Correct Answer
C. Procedural language
Explanation
A procedural language is a programming language that follows a linear, step-by-step approach to solving a problem. In procedural programming, data is given less importance compared to the sequence of instructions or procedures that manipulate the data. The focus is on writing procedures or functions that perform specific tasks. This approach is often used in languages like C, Pascal, and Fortran, where the emphasis is on breaking down a problem into smaller, manageable parts and executing them in a specific order. Therefore, data is not given as much significance as the sequence of instructions in a procedural language.
18.
Which of the following is an example of procedural programming language?
Correct Answer
B. ALGOL
Explanation
ALGOL is an example of a procedural programming language. Procedural programming focuses on writing step-by-step instructions or procedures to solve a problem. ALGOL, short for Algorithmic Language, was one of the earliest high-level programming languages developed in the late 1950s. It was designed to be used for scientific and engineering computations and featured a block structure, allowing for the creation of reusable code blocks. Although not widely used today, ALGOL played a significant role in the development of subsequent programming languages, influencing the design of languages like Pascal and C.
19.
Which command disassembles a class file?
Correct Answer
C. Javap
Explanation
The command "javap" is used to disassemble a class file in Java. It allows the user to view the bytecode instructions and other information about the class file. By running "javap" followed by the name of the class file, the user can see the structure, fields, and methods of the class in a human-readable format. This command is helpful for debugging and understanding the internal workings of a Java program.
20.
Java supports Unicode character set which is
Correct Answer
D. 16 bits
Explanation
Java supports Unicode character set which uses 16 bits to represent each character. Unicode is a universal character encoding standard that supports a wide range of characters from different scripts and languages. In Java, characters are represented using the UTF-16 encoding scheme, where each character is stored in 16 bits. This allows Java to handle and manipulate characters from various languages and scripts effectively.