Professional Documents
Culture Documents
=======================
0) Why Java is secure?
Java programs run inside a virtual machine which is known as a sandbox. Java
does not support explicit pointer.
Byte-code verifier checks the code fragments for illegal code that can violate
access right to object.
===================================================================================
=====================
1) what is Java?
Java is a widely used Object-Oriented Programming Language and Simple
Language. We run the same code on
multiple platforms. Java achieves this using JVM and Byte code.
===================================================================================
=====================
6) Features of Java?
Java is a versatile and popular programming language known for its simplicity,
portability, and robustness. I know some key features of Java:
* Simple.
* Interpreted.
* Multi-Threaded.
* Object-Oriented Programming Language.
* Open Source
* Platform independent.
* Portable.
* Robust.
* Secure.
===================================================================================
=====================
7) What type of tool you are using in your project to execute Java?
I execute my Java projects using Eclipse.
===================================================================================
=====================
9) What is Compiler?
A compiler is a special program that translates a programming language's
source code into machine code,
bytecode or another programming language.
===================================================================================
=====================
12) How to access one class method into another package in a different package?
Use the java import keyword which is used to access the package and its
classes into the java program.
===================================================================================
=====================
13) Coding standard to create project, class, method, package, and object?
Two types of Coding standards:
(i) Pascal notation:
Every word's first letter should start with Upper Case.
eg. GreensTechTrichy.
=> Project and Class.
(ii) Camel Notation:
For first words, the First letter should be lower case, and the remaining
words should start in Upper Case.
eg. greenTechTrichy.
=> method, object, and variable.
(iii) Package:
All letters should be in Lower case. => org. or com.
=> org.greenstechtrichy.
===================================================================================
=====================
14) What gives Java its "write once and run anywhere" nature?
Java's "write once, run anywhere" nature is mainly due to its bytecode
architecture and the Java Virtual Machine (JVM).
===================================================================================
=====================
C++
JAVA
(i) Compiled Programming language Compiled Programming
Language.
(ii) Supports Operator overloading Does not support Operator
Overloading.
(iii) C++ program is a fast compiling Java Program
compiler a bit slower than C++.
language.
===================================================================================
=====================
(i) Strings.
(ii) Arrays.
(iii) Interfaces.
(iv) Classes.
22) How will achieve multiple inheritance in Java, write a code for that.
Java does not support multiple inheritance. This means that a class cannot
extend more than one class parallely,
but we can still achieve the result using the keyword 'extends'.
===================================================================================
=====================
* Method Overriding:
When we are not satisfied with the parent class logics, we can create the
same method in our child class and we can write our
required business logic.
=> Different Classname.
=> Same Method name.
=> Same Arguments.
===================================================================================
=====================
28) What are the different methods available in the Scanner class?
* nextByte( );
* nextShort( );
* nextInt( );
* nextFloat( );
* nextLong( );
* nextDouble( );
* nextBoolean( );
* next ( );
* nextLine( ); ---->String
* next( ).charAt(0);
===================================================================================
=====================
40) How will achieve multiple inheritances in Java, write a code for that.
Using the interface, we can achieve multiple inheritances in Java.
===================================================================================
=====================
47) What is the difference between literal String and non-literal string?
* A literal String is a sequence of characters from the source character set
used by Java programmers to populate string
objects or to display text to a user. It is used to store inside the String pool
as a part of heap memory. In case of a duplicate, it
will share the memory.
* A non-literal String is also a sequence of characters from the source
character set, it is used to be stored directly in a
heap memory. In case of duplicate also it will store or share the different memory
locations.
===================================================================================
=====================
58) What is meant by the final keyword and what's happened when we declare the
final as in class, method, variable?
The final keyword restricts the access of the user to modify the data.
* Class = We can't inherit.
* Method = We can't override.
* Variable = We can't change the value.
===================================================================================
=====================
59) What is the difference between the final and finalize keywords?
Each of these keywords has a different functionality. The basic difference
between final, finally, and finalize is that the final is an
access modifier finally is the block in Exception Handling, and finalize is the
method of the object class.
===================================================================================
=====================
60) Where are local, static, and class variables stored in JVM?
It's all stored in Heap memory.
===================================================================================
=====================
* Breaking Statements:
- break;
- continue;
- System.exit(0);
===================================================================================
=====================
===================================================================================
=====================
Syntax:
======
datatype varName[]= new datatype[];
===================================================================================
=====================
75) Can you declare an array without assigning the size of an array?
Yes. We can declare an array without size but before using it needs to be
initialized.
===================================================================================
=====================
Disadvantages of Arrays:
- Arrays have a fixed size, making it difficult to add or remove
elements dynamically.
- Inserting or deleting elements in the middle of an array can be
inefficient.
- Arrays require contiguous memory, which can be a limitation in memory
allocation.
- Arrays generally lack dynamic resizing capabilities, requiring manual
reallocation and copying of elements.
===================================================================================
=====================
===================================================================================
=====================
This means that ArrayList is not thread-safe and may lead to issues in concurrent
environments if multiple threads try to modify
the list simultaneously. On the other hand, Vector is thread-safe, ensuring that
multiple threads can safely access and modify the
vector concurrently without causing data corruption.
In summary:
List: A list is a dynamic data structure that stores elements of any type and
can grow or shrink in size as needed. It provides more
flexibility compared to arrays as it allows for dynamic resizing and provides
convenient methods for adding, removing, and accessing
elements. Lists are implemented through various classes in Java's java.util
package, such as ArrayList, LinkedList, etc.
===================================================================================
=====================