1.
Name the principles of oops (object oriented programming system)
Encapsulation, Inheritance, Polymorphism, abstraction
2. What is an object?
Identifiable entity which contains characteristics and behavior.
3. what is source code?
Source code is the set of instructions and statements written by a programmer using
a computer programming language. This code is later translated into machine language by a
compiler.
4. what is byte code?
Compiled source code is byte code.
5. What is JVM ?
JVM is Java Virtual Machine. It converts byte code to machine code. Used for execution.
6. Name two packages used in java?
[Link], [Link] (default), [Link] package
7. Name the keyword applied to include a package?
import
8. What is a keyword?
Reserved word which is preserved by java system
9. What are the types of java programming?
Java applications and Java applets
10. What is a token ?
Each individual character available in a java statement is a token.
11. Name the types of token in java
Literal (constant / numbers )
Identifier (variable / alpha numeric )
Operator
Punctuator or Separator ( comma(,) semicolon (;) )
[Link] is literal ?
Constant which remains unchanged throughout the execution of the program.
[Link] is identifier ?
Named memory location which contains a constant.
[Link] a variable?
It is a named set of memory location. Value to the variable changes.
Example int m;
15. How will you declare a variable ? int x;
16. what is pure expression?
int a = b + c ; // here b and c are int (integer) all same data type.
[Link] is mixed expressions ?
Expressions which contains values of different types is known as mixed expressions.
Example : int a; double b; double c = a + b; // here a and b are different data type.
[Link] are library packages?
A package is a collection of classes. Ex [Link], [Link], [Link],
19. What is an operator?
An operator is a token which performs an operation and yield in a result.
[Link] is an operand? Operands are the contents on which an operation is performed to obtain a
meaning result.
[Link] are escape sequence? Give example
Non graphical characters which cannot be typed directly from the keyboard Begins with backslash.
It is given within the double quotes.
Example : “\t” – horizontal tab \n-newline
\0 – null \’ single quote \” double quote
22. What is ternary operator? Give example.
Conditional assignment operator. The assignment of the values are based on a condition Example :
int c = ( a > b ) ? a : b ;
23. Differentiate between if and switch statement?
Expression inside if statement decide expression inside switch statement
whether to execute the statements decide which case to execute
inside if block or under else block..
If-esle statement checks for equality as switch checks only for equality
well as for logical expression .
Sequence of execution is like either The expression in switch statement
statement under if block will execute or decide which case to execute and if you
statements under else block statement do not apply a break statement after
will execute.. each case it will execute till the end of
switch statement
If expression inside if turn outs to be If expression inside switch statement
false, statement inside else block will turn out to be false then default
be executed statements is executed
24. Explain the purpose of default in switch in java ?
When none of the case values are equal to the expression of switch statement then default case is
executed. In the example below, value of number is 4 so case 0, case 1 and case 2 are not equal to
number. Hence println statement of default case will get executed printing "Value of number is
greater than two" to the console.
int number = 4;
switch(number) {
case 0:
[Link]("Value of number is zero");
break;
case 1:
[Link]("Value of number is one");
break;
case 2:
[Link]("Value of number is two");
break;
default:
[Link]("Value of number is greater than two");
break;
}
25. what is the purpose of break in switch case in java?
When a break statement is reached, the switch terminates, and the flow of control jumps to the next
line following the switch statement. Not every case needs to contain a break. If no break appears,
the flow of control will fall through to subsequent cases until a break is reached.
26. what is fall through
It occurs in switch-case statements where when we forget to add break statement and in that case
flow of control jumps to the next line.
FALL THROUGH: If the break statement is not given in the switch statement then automatically
the control is transferred from one case to another but it should not. This situation is called fall
through.
27. What is compound statement or block ?
A compound statement consists of zero or more statements enclosed in curly braces ({ }). A
compound statement can be used anywhere a statement is expected. Compound statements are
commonly called "blocks."
28. What is function prototype?
A function prototype begins with the keyword function, then lists the function name, its parameters
(if any), and return value (if any). Example : void is prototype.
29. What is function signature?
Method name or function name with its arguments is called function signature.
30. What is the purpose served by the "import" keyword?
To import packages. (predefined or library)
31. Default values:
0 byte, short, int.
0l long
0.0f float
0.0d double
null character char (‘ ‘)
False boolean
null reference data type. (non-primitive or composite data type )
32. List the operators in java.
Operators: Arithmetic (* / % + - ), increment ( ++ ) , decrement ( - - ) , relational (< > <=
>= == !=), logical ( && , || ), shift bitwise operators (<< >> >>>) , assignment (=, = += -= *= /=
), conditional or ternary (?:) new , [ ] – array operators, dot operator,
Unary operators requires single operand
Eg --, ++ binary operator requires two operands a+b a and b are operands,
Ternary Operator:
variable = (condition) ? expression1 : expression2
ternary requires three operands (condition)? true : false.
Example :
int x = ( a > b ) ? a : b; if the condition is true a value is stored in x otherwise b value is
stored in x.
Example 2 : String s = (5>1) ? “PASS”: ”FAIL”;
Assignment operator can be done as many times as required, but initialization is done only once.