Tuesday, November 22, 2016

Java Ocjp Quiz


which of the following declarations are valid?choose all correct answer(s)?
1)int x=10;
2)int x=066;
3)int x=0786;
4)int x=0xFACE;
5)int x=0XBeer
6)int x=0xbea;

Options:
a)1,2,3,4,5,6
b)1,2,4,6
c)13,4,5,6
d)None of the above
which of the following declarations are not valid?
if not valid comment the reason? int a=10; int a=10l; long l=10l; long l=10; byte b=100; byte b=127; byte b=128; byte b=012; short s=200; short s=32768;

Advanced Java New Batch Schedule[December 1st]





Java Project[Core Java+servlets+jsp+ajax]

Dear Students,


Core Java[Variable declaration and initialization]

variable declaration and initialization

  • we can declare and initialize a variable as shown below,

Type1

  • datatype var=value;

Example

  • char ch='4';

Type2

  • datatype varname;


  • varname=value;


Example

  • char ch;
  • ch='4';



Declare and initialize character variable

  • char x='a';

Declare and initialize byte variable

  • byte x=10;

Declare and initialize short variable

  • short x=20;

Declare and initialize int variable

  • int x=40;

Declare and initialize long variable

  • long x=50;


Declare and initialize float variable

  • float x=10.5f;

Declare and initialize double variable

  • double x=10.5;

Declare and initialize boolean variable

  • boolean x=true;

Declare and initialize String variable

  • String x="manohar";


Monday, November 21, 2016

Core Java[Boolean Constants,Datatypes]

Boolean Constants


  • If  a  condition is evaluated it may either return true or false based on input given by user,here the boolean constants are true/false.
  • We must declare boolean constants in lowercase because both are predefined literals.



Datatype

  • datatype is keyword which tells about type of data we are using in a program.
  • datatype also allocates memory for a variable.


syntax


  • datatype varname;

 or

  • datatype var1,var2,....;


example:

  • char ch;




















Feedback By Java Project Implementation Students[By Manohar Papasani]


Dear Students,
                  Thank you very much for your feedback!!!!.






Saturday, November 19, 2016

New Core Java Batches of Mr.Manohar.

Morning -9-11AM[Just started]
Evening 4-6 PM[Just started]
Weekend batches-Saturday,Sunday.[Just started]
Advanced Java[December 1st].

Friday, November 18, 2016

Java Constants[session6]

Numeric constants

All numbers are numeric constants

They are 2 types

Integer constant
decimal/real/floating-point constant.

Integer constant
Number without fractional part is called integer constant.

Example:

10
20
56

Decimal constant.
Number with fractional part is called decimal constant.

Example:

10.7
5.6

we can represent integer constant  in the following number systems.
i)Decimal(regular).
ii)Binary.
iii)Octal.
iv) Hexa decimal number systems.

Decimal number system
It has base as 10 i,e it consists base numbers from 0 to 9

Example:

  19
   20
   1
   158


Binary number system
It has base as 2 i,e it consists of digits 0 or 1.

Example:
   010
   110
   etc


Converting decimal to binary
If we want to convert decimal number to binary we should perform lcm using 2.

536   --> ?
  10      2

2|536
  ---
2|268-0
  ---
2|134-0
  ---
2|67-0
  --
2|33-1
  ----
2|16-1
  ----
2|8-0
  ---
2|4-0
  --
2|2-0
 ----
2|1-0
  ---
2|0-1


Collect  remainders from bottom to top

536-->1000011000

Converting binary to decimal
1    0   0   0    0     1   1    0    0    0
2^9 2^8 2^7  2^6  2^5  2^4  2^3  2^2  2^1  2^0


2^9*1+2^8*0+..........+2^0*0.

512+0+.......+0

536

Octal number system
It has a base as 8 i'e  it has digits from 0 to 7.
Always an octal integer must have a prefix 0[zero].

Example:
   0123(v)
   012(v)
   123(iv)
   078(iv)

Converting decimal to octal
36--> ?
10   8


8|36
  --
8|4-4
  ---
8|0-4

octal-->044

Converting octal to decimal
044-->     ?
            10

0   4    4
8^2 8^1  8^0


0+32+4-->36


Hexa decimal system
It has base as 16 i'e it consists altogether digits from 0 to 15

0 to 9[digits]

from 10-15 we should substitute alphabets a-f


10->a or A
11->b or B
12->c or C
13->d or D
14->e or E
15->f or F


It should have a prefix 0x or 0X


Example:

0x123
0xabc
0xface
etc

Converting decimal to hexa decimal

16|90
   --
16|5-10
   ----
16|0-5


ans->0x5A







Core Java[Session5]


  1. Constants

  2. Constant is a fixed value.

  3. There are 3 types of constants.

  4. i)character
  5. ii)Numeric
  6. iii)Boolean



  7. character constants
  8. -------------------
  9. character constants are 

  10. i)words.
  11. ii)alphabets[a-z,A-Z].
  12. iii)digits[0-9].
  13. iv)special symbols.

  14. character constants are of 2 types.

  15. i)single character constants
  16. ii)String constants.

  17. i)single chracter constant
  18. --------------------------
  19. single character enclosed in single quotes is known as 
  20. single character constant.

  21. ex:
  22.   'a'
  23.   'x'
  24.   '5'
  25.   '*'
  26.   ''
  27.    '10'(ic)
  28.    'abc'(ic)

  29. String constants
  30. ----------------
  31. group of letters enclosed in double quotes is known as 
  32. string constant.

  33. ex:
  34.    "satya"
  35.    "satya123"
  36.    ""
  37.    " "
  38.    "a"
  39.    "12345"
  40.    

  41. Numeric constants
  42. -----------------
  43. All numbers are numeric constants

  44. They are 2 types 

  45. Integer constant

  46. decimal/real/floating-point constant.

  47. Integer constant
  48. ----------------
  49. Number without fractional part is called integer constant.

  50. ex:
  51. 10
  52. 20 
  53. 56

  54. decimal constant.
  55. -----------------
  56. Number with fractional part is called decimal constant.

  57. ex:10.7 
  58. 5.6



Wednesday, November 16, 2016

Core Java Notes[session4]

Language fundamentals
---------------------
1)variables
2)keywords
3)constants
4)datatypes
5)operators


variable
--------
*Variable is an identifier which identifies a value,whose value changes.

syntax
------
datatype variablename;

ex:
 int a;


Rules for declaring variables
-----------------------------
*A variable should start with alphabet or underscore or dollar.

*No special symbols are allowed in a varible except underscore(_) and dollar($)

*No blank spaces are allowed in a variable.


ex:
v-valid
iv-invalid
a(v)
b(v)
abc123(v)
123abc(IV)
a_bc_c(v)
a+b+c(iv)
a bc(v)
s_(v)
_$(v)
$123(v)
%@abc(iv)
$(v)
_(v)


Keywords
--------
*keywords are builtin or predefined words.

*There are around 53 keywords in  java

ex:
int
char
float
double
long
while
do
for
class
etc

Rules for declaring keywords
----------------------------
i)A keyword must be declared in lowercase.

ii)we cannot use keywords as identifiers.


ex:
c-correct
ic-incorrect

INT(ic)
Float(ic)
while(c)

int int;(iv)

int x;(c)


Core Java Notes[session3]


  1. Features  of java
  2. -----------------
  3. i)Platform independent
  4. ----------------------
  5. *java is platform independent because we can execute .class[bytecode] of one os on nay other os.

  6. 2)Object Oreinted
  7. -----------------
  8. Java is object oriented because it consists of objects and classes.

  9. 3)Portable
  10. ----------
  11. *Bothe java s/w and java bytecode can be executed on different os's so java is portable.


  12. 4)simple
  13. --------
  14. Java is developed from c and c++,so learning java is simple.

  15. 5)robust[strong)
  16. ---------------
  17. *Java programs do not crash easily because of exception handling mechanism so java is robust.

  18. 6)interpreted
  19. --------------
  20. As jvm interprets bytecode to machine code,java is called interpreted language.

  21. 7)secured
  22. ---------
  23. Java is secured because virus don't attack .class files,also java is robust.

  24. 8)distributed
  25. --------------
  26. we can run java programs on different os's so we cab say java is distributed.

  27. 9)Multi-threaded
  28. --------------- 
  29. Thread
  30. ------
  31. *Thread is an independent part of a program.

  32. *Multithreading is group of threads executing parallely to accomplish a task.


Core Java Notes[(session2)]


  1. Execution Process c and cpp program
  2. *if we develop any program it has to undergo 2 phases

  3. i)compilation
  4. ii)execution

  5. if we compile a c/cpp program we get an intermediate code called as .obj file.

  6. *we execute or convert .obj into .exe using a program called Linker.

  7. *.exe is when executed provides output.


  8. Here either .obj or .exe of one os cannot be executed on other os,so c/cpp are platform dependent.


  9. .c/.cpp-->compile-->.obj-->Linker-->.exe



  10. Execution Process of a java program


  11. .java--->comiple-->.class[bytecode]--->Jvm-->o/p
  12.                                        Jit

  13. *we save a java program using the extension .java

  14. *Execution of a java program undergoes 2 phases

  15. i)compilation
  16. ii)execution

  17. i)compilation

  18. *if we compile a .java program we get .class[bytecode]

  19. .java-->compiled-->.class[bytecode]

  20. *once we get a .class again we should convert bytecode to machine code using jvm[java virtual machine]

  21. *Jvm is a program which helps in converting bc to mc

  22. .class-->jvm-->o/p

  23. *.class is platform independent code,we can execute the .class file of one os on another os.

  24. *.class is interpreted by jvm so jvm is also called as bytecode interpretor.

  25. *jvm is platform dependent bcoz every os should have a seperate jvm.

  26. what is JIT compiler?

  27. It is a helper application of jvm which helps jvm to convert byte code to mahcine code together.


  28. .java-->compile-->.class-->jvm-->o/p. 


Java Introduction[Session1]

Platform 

*A platform is an environment where we can execute different programs.

ex:
  os(windows,linux,unix etc)
  technology(java,.net etc)

Platform Dependent
------------------
*If application of one operating system cannot be executed on other operating system such kind of application is called as platform dependent.
ex:
 c/c++ Applications

Platform Independent
--------------------
If  application of one os can be executed on other os such kind of applications are called platform independent.
ex:
Java applications


History of java
---------------
*In early 1990's sunmicrosystems was developing a software for electronic devices.


*At that time c/c++ are the most powerful languages but they are platform dependent.

*so sunmicrosystems started to develop a new programming language which is platform independent under the guidance of James Gosling.

*The name of the project is Green Project.

*By 1992 they had developed a platform independent language.

*Initially it is named as oak

*In 1995 oak is renamed to java due to patent issue.