[Go to site: main page, start]

0% found this document useful (0 votes)
6 views3 pages

Java Examination Questions February 2024

The document outlines a Java examination for February 2024, consisting of multiple-choice questions in Part A, short answer questions in Part B, and programming tasks in Part C. It covers various Java concepts, including data types, arrays, methods, and object-oriented programming principles. The exam is structured to assess knowledge of Java programming and its features.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Java Examination Questions February 2024

The document outlines a Java examination for February 2024, consisting of multiple-choice questions in Part A, short answer questions in Part B, and programming tasks in Part C. It covers various Java concepts, including data types, arrays, methods, and object-oriented programming principles. The exam is structured to assess knowledge of Java programming and its features.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

[JAVA EXAMINATION]

(February-2024)
PART-A(20*1=20)

1. Number Of Primitive Data Types In Java Are?


A)6 B)7 C)8 D)9
2. What Is The Size Of Float And Double In Java?
A)32 And 64 B)32 And 32 C)64 And 64 D)64 And 32
[Link] Type Conversion Is Possible In Which Of The Possible Cases?
A) Byte To Int B) Int To Long C) Long To Int
D) Short To Int
4. Find The Output Of The Following Code.
Int Integer = 24;
Char String = ‘I’;
[Link](Integer);
[Link](String);
A) Compiler Error B) Throws Exception C)1 D)241
6. Find The Output Of The Following Program.
Public Class Solution{
Public Static Void Main(String[] Args){
Byte X = 127;
X++;
X++;
[Link](X);
}
}
A)127 B)-127 C)129 D)2
7, Select The Valid Statement.
A) Char[] Ch = New Char(5) B)Char[] Ch = New Char[5]
C)Char[] Ch = New Char() D)Char[] Ch = New Char[]

[Link] The Output Of The Following Program.


Public Class Solution{
Public Static Void Main(String[] Args){
Int[] X = {120, 200, 016};
For(Int I = 0; I < [Link]; I++){
[Link](X[I] + “ “);
}
}
}
A)120 200 016 B)120 200 14 C)120 200 16
D)None
9. When An Array Is Passed To A Method, What Does The Method Receive?
A) The Reference Of The Array B) A Copy Of The Array C) Length Of The
Array D) Copy Of First Element
10. Select The Valid Statement To Declare And Initialize An Array.
A) Int[] A = {} B)Int[] A = {1, 2, 3} C)Int[] A = (1, 2, 3)
D)Int[][] A = {1,2,3}
[Link] The Value Of A[1] After Execution Of The Following Program.
Int[] A = {0,2,4,1,3};
For(Int I = 0; I < [Link]; I++){
A[I] = A[(A[I] + 3) % [Link]];
}
0 B)1 C)2 D)3

12. Arrays In Java Are-


A) Object References B) Objects C) Primitive Data Type
D) None
13. When Is The Object Created With New Keyword?
A) At Run Time B) At Compile Time C) Depends On The Code
D) None
[Link] The Corrected Definition Of A Package.
A)A Package Is A Collection Of Editing Tools B)A Package Is A Collection Of
Classes C)A Package Is A Collection Of Classes And Interfaces
D) Package Is A Collection Of Interfaces
15. Identify The Keyword Among The Following That Makes A Variable Belong To A
Class, Rather Than Being Defined For Each Instance Of The Class.
Final
Static
Volatile
Abstract
16. In Which Of The Following Is Tostring() Method Defined?
A)[Link] B)[Link] C)[Link]
D)None
17. Compareto() Returns
A)True B)False C)An Int Value D)None
18. Identify The Output Of The Following Program.
String Str = “Abcde”;
[Link]([Link](1, 3));
A)Abc B)Bc C)Bcd D)Cd

19. Identify The Output Of The Following Program.


String Str = “Hellow”;
[Link]([Link](‘T));
A)0 B)1 C)-1 D)True
20. Identify The Output Of The Following Program.
Public Class Test{
Public Static Void Main(String Argos[]){
String Str1 = “One”;
String Str2 = “Two”;
[Link]([Link](Str2));
}
}
A) One B) Two C) Onetwo D)Twoone

PART-B(5*3=15)
[Link] Is The Most Important Feature Of Java?

[Link] Between A JDK And A JVM?

[Link] The Significance Of Static Variable?

[Link] Is An Abstract Class And What Is Its Purpose?

[Link] Are Differences Between Interface And Abstract Class?

[Link] Are Differences Between Class And Abstract Class?

[Link] Between Method Overriding And Overloading?

[Link] Are Differences Between This Keyword And Super Keyword?

Part-C(3*5=15)
[Link] A Program For Multithreading Using Synchronized Method?

[Link] Is Serialization And De-Serialization With Coding?

[Link] Can You Create A Table Into Database Using Jdbc?

[Link] Is Abstract Class? Explain In Detail.

5. What Is Servlet? Explain In Detail.

Common questions

Powered by AI

Method overloading occurs when several methods within the same class share the same name but differ in parameters (e.g., type, number), allowing for different implementations to be selected based on varying data inputs . It's beneficial for enhancing readability and organization, allowing a single method name to address similar actions, such as printing different types of content. Method overriding, in contrast, allows a subclass to provide a specific implementation of a method that is already defined in its superclass . This is useful for dynamic polymorphism, where subclass behavior customizes inherited functionality to suit specific needs .

In Java, the 'new' keyword is used to instantiate objects, calling the class constructor to allocate memory during runtime . This ensures that objects are not created at compile time, allowing for more flexible and dynamic resource management. At runtime, memory is allocated on the heap, meaning each 'new' operation can result in a unique memory address for the created object, critical for managing varied program states and dynamic lifecycles . This dynamic instantiation supports complex systems that instantiate objects based on runtime conditions, enhancing Java's flexibility across different use cases .

The 'static' keyword in Java is used to denote that a member (variable or method) belongs to the class itself, rather than to any specific instance of the class. This means that static members are shared across all instances, offering a memory-efficient way to share constant data or methods intended to operate independently of instance-specific data . Unlike instance variables, which hold values specific to each object, static variables have a single shared copy, reducing redundancy . This is especially beneficial for methods that do not alter object state and for defining singleton-like members, ensuring consistent and controlled access throughout an application .

Java handles automatic type conversion predominantly when smaller data types are converted into larger data types, which is also called widening conversion. For example, converting a byte to an int or an int to a long . This implicit conversion happens without data loss. However, if a conversion might result in data loss, such as long to int, it requires explicit casting by the programmer, as automatic type conversion will not occur .

Serialization in Java allows an object's state to be converted into a byte stream, which can be easily stored or transmitted, while deserialization allows those byte streams to be converted back into replica objects . This mechanism is fundamental for deep reutilization of objects across diverse environments, such as saving objects to disk or sending them over a network. Its cross-platform capabilities stem from Java's platform-independent serialization format, making serialized objects compatible across different Java virtual machines. It underpins persistent storage and is crucial for remote communication processes like RMI (Remote Method Invocation), enhancing Java's capabilities as a network-aware, distributed language .

A synchronized method in Java ensures that only one thread can execute it at any given time, providing a mechanism to prevent race conditions and ensure thread safety when accessing shared resources . This synchronization helps maintain data integrity across concurrent threads, essential for avoiding unpredictable program behavior. However, synchronizing methods can lead to performance drawbacks, such as increased latency and reduced throughput, due to the enforced lock contention management, which can cause bottlenecks and limit parallelism . Especially in highly concurrent applications, excessive use of synchronization can lead to thread contention issues, impacting performance .

Arrays in Java are considered objects because they encapsulate data and the functionality to manage data as a collection, supporting operations like indexing and length retrieval. They are instances of a special kind of class that extends Java's base class, java.lang.Object. This allows them to participate in Java's object memory model, adhere to inheritance rules, and utilize methods such as clone(). The object nature of arrays distinguishes them from primitive types, which are simple data holders without such behavior .

An abstract class in Java can have both abstract methods (without body) and concrete methods (with body), and it can also have fields with any access modifier, including private. Additionally, an abstract class can have constructors and be extended only a single time due to Java's single inheritance feature . An interface, on the other hand, is similar to a contract where the implementing class must provide implementations for all its methods. Interfaces can only have abstract methods (prior to Java 8) and static or default methods (from Java 8 onwards), and fields are implicitly public, static, and final. Interfaces support multiple inheritance, allowing a class to implement multiple interfaces .

The Java Virtual Machine (JVM) is an abstract computing machine that enables Java bytecode execution on any platform, acting as the runtime environment that offers Java's platform independence by translating bytecode into machine code . It handles runtime activities such as memory management and garbage collection. The Java Development Kit (JDK), in contrast, is a development package necessary for developing Java applications, containing tools for code compilation, debugging, and documentation, including the JVM and additional libraries and utilities . While the JVM runs Java programs, the JDK is essential for developing and compiling Java applications, making them complementary in both executing and creating Java applications .

The 'this' keyword in Java refers to the current instance of a class, commonly used to disambiguate between class attributes and parameters or to call other constructors within the same class . 'Super', on the other hand, refers to the superclass of the current object, enabling access to the superclass's methods and constructors that might be overshadowed by the subclass . Together, they enhance object-oriented programming by facilitating a clear and organized way to bridge subclass and superclass interactions, ensuring access to inherited features while also managing class-specific behavior .

You might also like