Saraswat World
Explain Java Coding standards for Methods?
1) Method names should start with small letters.2) Method names are usually verbs3) If method contains multiple words, every inner word should start with uppercase letter.Ex : toString()4) Method name must be combination of verb and nounEx : getCarName(),getCarNumber()
Explain Java Coding standards for interfaces?
1) Interface should start with uppercase letters2) Interfaces names should be adjectivesExample : Runnable, Serializable, Marker, Cloneable
Explain Java Coding Standards for classes or Java coding conventions for classes?
Sun has created Java Coding standards or Java Coding Conventions . It is recommended highly to followjava coding standards.Classnames should start with uppercase letter. Classnames names should be nouns. If Class name is ofmultiple words then the first letter of inner word must be capital letter.Ex : Employee, EmployeeDetails, ArrayList, TreeSet, HashSet
Difference between Right shift operator ‘>>’ and Unsigned shift operator ‘>>>’ in java?
The right shift operator ‘>>’ shifts all of the bits in a value to the right to a specified number of times.int a =15;a= a >> 3;The above line of code moves 15 three characters right. The unsigned shift operator ‘>>>’ used to shift right. The places which were vacated by shift are filledwith zeroes.
What are constants and how to create constants in java?
Constants are fixed values whose values cannot be changed during the execution of program. We createconstants in java using final keyword.Ex : final int number =10;final String str=”java-interview –questions”
What is difference between Character Constant and String Constant in java ?
Character constant is enclosed in single quotes. String constants are enclosed in double quotes. Characterconstants are single digit or character. String Constants are collection of characters.Ex :’2’, ‘A’Ex : “Hello World”
What is Unicode ?
Unicode is a character set developed by Unicode Consortium. To support all languages in the world Javasupports Unicode values. Unicode characters were represented by 16 bits and its character range is 0-65,535.Java uses ASCII code for all input elements except for Strings, identifiers, and comments.
What is ASCII Code?
ASCII stands for American Standard code for Information Interchange. ASCII character range is 0 to 255.We can’t add more characters to the ASCII Character set. ASCII character set supports only English. That13is the reason, if we see C language we can write c language only in English we can’t write in otherlanguages because it uses…
What is difference between length and length() method in java
length() : In String class we have length() method which is used to return the number of characters instring.Ex : String str = “Hello World”;System.out.println(str.length());Str.length() will return 11 characters including space.length : we have length instance variable in arrays which will return the number of values or objects inarray.For example :String days[]={” Sun”,”Mon”,”wed”,”thu”,”fri”,”sat”};Will return 6…
What is constructor in java ?
A constructor is a special method used to initialize objects in java.we use constructors to initialize all variables in the class when an object is created. As and when an objectis created it is initialized automatically with the help of constructor in java.We have two types of constructorsDefault ConstructorParameterized ConstructorSignature : public classname(){}Signature : public…
Why main() method is public, static and void in java ?
public : “public” is an access specifier which can be used outside the class. When main method is declaredpublic it means it can be used outside class.static : To call a method we require object. Sometimes it may be required to call a method without thehelp of object. Then we declare that method as static.…
What is encapsulation ?
The process of wrapping or putting up of data in to a single unit class and keeps data safe from misuse is called encapsulation . Through encapsulation we can hide and protect the data stored in java objects. Java supports encapsulation through access control. There are four access control modifiers in java public , private,…
What is method in java ?
It contains the executable body that can be applied to the specific object of the class.Method includes method name, parameters or arguments and return type and a body of executable code.Syntax : type methodName(Argument List){}ex : public float add(int a, int b, int c)methods can have multiple arguments. Separate with commas when we have multiple…
What is a class in Java?
Classes are fundamental or basic unit in Object Oriented Programming . A class is kind of blueprint or template for objects. Class defines variables, methods. A class tells what type of objects we are creating. For example take Department class tells us we can create department type objects. We can create any number of department…
What is the difference between this() and super() in java ?
this() is used to access one constructor from another with in the same class while super() is used to access superclass constructor. Either this() or super() exists it must be the first statement in the constructor.
What is bytecode in java ?
When a javac compiler compiler compiles a class it generates .class file. This .class file contains set of instructions called byte code. Byte code is a machine independent language and contains set of instructions which are to be executed only by JVM. JVM can understand this byte codes.
What is JIT compiler ?
JIT compiler stands for Just in time compiler. JIT compiler compiles byte code in to executable code . JIT is a part of JVM . JIT cannot convert complete java program in to executable code it converts as and when it is needed during execution.
What is method overloading in java ?
A class having two or more methods with same name but with different arguments then we say that those methods are overloaded.Static polymorphism is achieved in java using method overloading.Method overloading is used when we want the methods to perform similar tasks but with different inputs or values.When an overloaded method is invoked, java first…
Why java is platform independent?
The most unique feature of java is platform independent. In any programming language source code is compiled in to executable code . This cannot be run across all platforms. When javac compiles a java program it generates an executable file called .class file. Class file contains byte codes. Byte codes are interpreted only by JVM’s…
What is the difference between abstract class and interface ?
Abstract Class VS Interface Sr. Abstract Class Interface 1 Abstract class can contain abstract methods, concrete methods or both Interface contains only abstract methods 2 Except private we can have any access specifier for methods in abstract class. Access Specifiers for methods in interface must be public 3 Except private variables can have any access…